Module: UserImpersonate::DeviseHelpers::Helpers

Defined in:
lib/user_impersonate/devise_helpers.rb

Instance Method Summary collapse

Instance Method Details

#impersonate(new_user) ⇒ Object

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



7
8
9
10
# File 'lib/user_impersonate/devise_helpers.rb', line 7

def impersonate(new_user)
  session[:staff_user_id] = current_user.id # 
   new_user, bypass: true
end

#revert_impersonateObject

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



14
15
16
17
18
# File 'lib/user_impersonate/devise_helpers.rb', line 14

def revert_impersonate
  return unless current_staff_user
   current_staff_user, bypass: true
  session[:staff_user_id] = nil
end