You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
As a way to provide support to end users, the ability to login to their rails app as a specific user can be useful. If you're using ActiveAdmin and Devise, adding this feature takes less than 10 minutes.
The feature consisted of two changes, customising the ActiveAdmin User show page and adding a custom member action that logs in the user.
Code Snippet 1-a: show page
showdo |user|
attributes_tabledo# Your existing columns# row(:id)# ...# This is where we add a new columnrow:login_asdoform_foruser,url: login_as_admin_user_path(user),method: :postdobutton"#{user.full_name}"endendendend
# Allows admins to login as a usermember_action:login_as,method: :postdouser=User.find(params[:id])# DO NOT forget this line, if you have multiple roles that can access your admin!authorize!(:login_as,user)bypass_sign_inuserredirect_toaccount_pathend
....And there you have it. Now admin users can quickly log in as any user for quick trouble shooting, user testing, etc.