You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
40 lines
1.7 KiB
40 lines
1.7 KiB
SwitchUserController.skip_before_filter :authenticate_user! |
|
|
|
SwitchUser.setup do |config| |
|
# provider may be :devise or :authlogic |
|
config.provider = :devise |
|
|
|
# available_users is a hash, |
|
# key is the model name of user (:user, :admin, or any name you use), |
|
# value is a block that return the users that can be switched. |
|
config.available_users = { :user => lambda { User.all } } |
|
|
|
# available_users_identifiers is a hash, |
|
# keys in this hash should match a key in the available_users hash |
|
# value is the name of the identifying column to find by, |
|
# defaults to id |
|
# this hash is to allow you to specify a different column to |
|
# expose for instance a username on a User model instead of id |
|
config.available_users_identifiers = { :user => :id } |
|
|
|
# available_users_names is a hash, |
|
# keys in this hash should match a key in the available_users hash |
|
# value is the column name which will be displayed in select box |
|
config.available_users_names = { :user => :email } |
|
|
|
# controller_guard is a block, |
|
# if it returns true, the request will continue, |
|
# else the request will be refused and returns "Permission Denied" |
|
# if you switch from "admin" to user, the current_user param is "admin" |
|
config.controller_guard = lambda { |current_user, request| Rails.env.development? } |
|
|
|
# view_guard is a block, |
|
# if it returns true, the switch user select box will be shown, |
|
# else the select box will not be shown |
|
# if you switch from admin to "user", the current_user param is "user" |
|
config.view_guard = lambda { |current_user, request| Rails.env.development? } |
|
|
|
# redirect_path is a block, it returns which page will be redirected |
|
# after switching a user. |
|
config.redirect_path = lambda { |request, params| '/' } |
|
end
|
|
|