Skip to content

Latest commit

 

History

History
24 lines (20 loc) · 795 Bytes

mimic-user.md

File metadata and controls

24 lines (20 loc) · 795 Bytes
title nav_text category order
Kingsman How To: Sign in as another user if you are an admin
Mimic User
kingsman-howtos
6

The ability to mimic or sign in as another user is a useful administration feature. Here's how you can can quickly "become" one of the users to see what their profile and screens look like.

class Admin::UsersController < AdminController
  def become
    return unless current_user.admin?
    user_params = params.require(:user).permit(:id)
    mimic_user = User.find(user_params[:id])
    bypass_sign_in(mimic_user, scope: :user)
    redirect_to root_url
  end
end

Note: This is based on Devise How To: Sign in as another user if you are an admin