Class: UsersController
- Inherits:
-
ApplicationController
- Object
- ApplicationController
- UsersController
- Defined in:
- app/controllers/users_controller.rb
Instance Method Summary collapse
- #create ⇒ Object
- #detect_existence ⇒ Object
- #index ⇒ Object
- #make_admin ⇒ Object
- #new ⇒ Object
- #remove_admin ⇒ Object
Instance Method Details
#create ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 |
# File 'app/controllers/users_controller.rb', line 15 def create @user = User.new(user_params) set_target_page if @user.save [:auth_token] = @user.auth_token # logging in the user redirect_to session[:target_page] || safe_root_url, notice: t('authentication.signup_confirmation') session[:target_page] = nil else render "new" end end |
#detect_existence ⇒ Object
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'app/controllers/users_controller.rb', line 27 def detect_existence set_target_page @detected_email = params[:user][:email] user = User.where('email = ?',@detected_email).first if user && !user.password_digest.blank? && user.password != 'temporary' flash[:notice] = "Our records show you have an account with us. Please login." redirect_to login_path(email: @detected_email) else if user newbie = Newbie.where('email = ?', params[:user][:email]).first else newbie = Newbie.create(email: params[:user][:email]) end newbie.send_password_set flash[:notice] = "Our records show you do not have an account with us. We need to verify your email address. Please check your email inbox (or spam filter if you have nothing after several minutes) and click on the confirmation link." redirect_to safe_root_url end end |
#index ⇒ Object
6 7 8 9 |
# File 'app/controllers/users_controller.rb', line 6 def index @users = User.by_recent render layout: 'admin' end |
#make_admin ⇒ Object
46 47 48 49 50 51 |
# File 'app/controllers/users_controller.rb', line 46 def make_admin user = User.find(params[:id]) user.admin = true user.save redirect_to members_path, notice: t('authentication.admin_enabled_confirmation') end |
#new ⇒ Object
11 12 13 |
# File 'app/controllers/users_controller.rb', line 11 def new @user = User.new end |
#remove_admin ⇒ Object
53 54 55 56 57 58 |
# File 'app/controllers/users_controller.rb', line 53 def remove_admin user = User.find(params[:id]) user.admin = false user.save redirect_to members_path, notice: t('authentication.admin_disabled_confirmation') end |