Module: UcbRailsUser::Concerns::ImpersonationsController
- Extended by:
- ActiveSupport::Concern
- Included in:
- ImpersonationsController
- Defined in:
- app/controllers/ucb_rails_user/concerns/impersonations_controller.rb
Instance Method Summary collapse
Instance Method Details
#create ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'app/controllers/ucb_rails_user/concerns/impersonations_controller.rb', line 12 def create target = User.find_by(id: params[:ucb_rails_user_impersonation][:target_id]) if logged_in_user.impersonate!(target) flash[:info] = "You are now impersonating #{target.full_name}" return redirect_to "/" else if target&.id == logged_in_user.id flash[:error] = "Sorry - you can't impersonate yourself." else flash[:error] = "Unable to start impersonating - please try again" end return redirect_to action: :index end end |
#index ⇒ Object
8 9 10 |
# File 'app/controllers/ucb_rails_user/concerns/impersonations_controller.rb', line 8 def index end |
#stop_impersonation ⇒ Object
27 28 29 30 31 |
# File 'app/controllers/ucb_rails_user/concerns/impersonations_controller.rb', line 27 def stop_impersonation logged_in_user.stop_impersonation! flash[:info] = "You are no longer impersonating." redirect_to request.referer || "/" end |