Module: MnoEnterprise::ImpersonateHelper

Defined in:
app/helpers/mno_enterprise/impersonate_helper.rb

Instance Method Summary collapse

Instance Method Details

#current_impersonatorObject



21
22
23
24
# File 'app/helpers/mno_enterprise/impersonate_helper.rb', line 21

def current_impersonator
  return unless session[:impersonator_user_id]
  @admin_user ||= MnoEnterprise::User.find(session[:impersonator_user_id])
end

#impersonate(new_user) ⇒ Object

current_user changes from a staff user to new_user; current user stored in session[:impersonator_user_id]



6
7
8
9
10
# File 'app/helpers/mno_enterprise/impersonate_helper.rb', line 6

def impersonate(new_user)
  session[:impersonator_user_id] = current_user.id
  sign_out(current_user)
   new_user
end

#revert_impersonateObject

revert the current_user back to the staff user stored in session[:impersonator_user_id]



14
15
16
17
18
19
# File 'app/helpers/mno_enterprise/impersonate_helper.rb', line 14

def revert_impersonate
  return unless current_impersonator
  sign_out(current_user)
  (current_impersonator)
  session[:impersonator_user_id] = nil
end