Class: BlueLightSpecial::ImpersonationsController
- Inherits:
-
ApplicationController
- Object
- ApplicationController
- BlueLightSpecial::ImpersonationsController
- Defined in:
- app/controllers/blue_light_special/impersonations_controller.rb
Instance Method Summary collapse
Instance Method Details
#create ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'app/controllers/blue_light_special/impersonations_controller.rb', line 11 def create user = User.find(params[:user_id]) if user == current_user flash[:failure] = "Cannot impersonate yourself" redirect_to root_url else unless session[:admin_user_id] session[:admin_user_id] = current_user.id session[:impersonation_hash] = Impersonation.hash_for(current_user.id) end session[:impersonation_back_url] = request.env["HTTP_REFERER"] sign_in(user) redirect_to root_url end end |
#destroy ⇒ Object
27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'app/controllers/blue_light_special/impersonations_controller.rb', line 27 def destroy if Impersonation.valid_hash?(session[:admin_user_id], session[:impersonation_hash]) old_user = current_user admin_user = User.find(session[:admin_user_id]) session[:admin_user_id] = nil session[:impersonation_hash] = nil sign_in(admin_user) redirect_to session[:impersonation_back_url] else deny_access end end |
#index ⇒ Object
6 7 8 9 |
# File 'app/controllers/blue_light_special/impersonations_controller.rb', line 6 def index @users = User.all render :template => 'impersonations/index' end |