Module: UserImpersonate::DeviseHelpers::Helpers
- Defined in:
- lib/user_impersonate/devise_helpers.rb
Instance Method Summary collapse
-
#impersonate(new_user) ⇒ Object
current_user changes from a staff user to
new_user
; current user stored insession[:staff_user_id]
. -
#revert_impersonate ⇒ Object
revert the
current_user
back to the staff user stored insession[:staff_user_id]
.
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 # sign_in new_user, bypass: true end |
#revert_impersonate ⇒ Object
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 sign_in current_staff_user, bypass: true session[:staff_user_id] = nil end |