devise - Rails: Switch User Gem and issues with switching back to original user -


in app using switch_user (https://github.com/flyerhzm/switch_user) gem allow admins login user. gem has ability log in admin, having hard time conceptualizing how it.

here config:

switchuser.setup |config|   # provider may :devise, :authlogic, :clearance, :restful_authentication, :sorcery, or :session   config.provider = :devise    # available_users hash,   # key model name of user (:user, :admin, or name use),   # value block return users can switched.   config.available_users = { :user => lambda { user.all } }    # available_users_identifiers hash,   # keys in hash should match key in available_users hash   # value name of identifying column find by,   # defaults id   # hash allow specify different column   # expose instance username on user model instead of id   config.available_users_identifiers = { :user => :id }    # available_users_names hash,   # keys in hash should match key in available_users hash   # value column name displayed in select box   config.available_users_names = { :user => :email }    # controller_guard block,   # if returns true, request continue,   # else request refused , returns "permission denied"   # if switch "admin" user, current_user param "admin"   config.controller_guard = lambda { |current_user, request, original_user|      current_user.school_admin? || original_user.school_admin?   }    # view_guard block,   # if returns true, switch user select box shown,   # else select box not shown   # if switch admin "user", current_user param "user"   config.view_guard = lambda { |current_user, request, original_user|      current_user.school_admin? || original_user.school_admin?   }    # redirect_path block, returns page redirected   # after switching user.   config.redirect_path = lambda { |request, params| '/' }    # helper_with_guest boolean value, if set false   # guest item in helper won't shown   config.helper_with_guest = true    # false = login 1 scope , logged in in both scopes   # true = logged 1 scope @ time   config.login_exclusive = true    # switch_back allows switch selected user. see   # readme more details.   config.switch_back = true end 

their readme says can have these links in view

<%= link_to user.login, "/switch_user?scope_identifier=user_#{user.id}" %> <%= link_to admin.login, "/switch_user?scope_identifier=admin_#{admin.id}" %> 

but there no way load "original user" check see if need display admin login link.. else have experience using gem?

i had similar issues switch user , switching option, @ end trying implement myself.

i'm using this starting point, hope helps well.


Comments

Popular posts from this blog

css - Which browser returns the correct result for getBoundingClientRect of an SVG element? -

gcc - Calling fftR4() in c from assembly -

Function that returns a formatted array in VBA -