-
Notifications
You must be signed in to change notification settings - Fork 204
Scopes
Brooks Swinnerton edited this page Sep 16, 2015
·
11 revisions
Warden allows for multiple users to be logged in at the same time. This should be used very cautiously.
Sudo access, or a publisher checking what viewing it as another user will look like, or a secured authentication step for checkout. You could also use scopes to authenticate a user’s access to a particular account.
By default the scope is :default. The :default scope is used whenever no scope is stated.
A scope is identified by an object. (I would use a symbol usually)
# Check the :sudo scope
env['warden'].authenticated?(:sudo)
# Authenticate the :sudo scope with the :pgp strategy
env['warden'].authenticate(:pgp, :scope => :sudo)
# The same options are available for #authenticate and #authenticate!
env['warden'].user(:sudo)
env['warden'].logout # Clear the session. Logs everyone out
env['warden'].logout(:default) # logout the :default user
env['warden'].logout(:admin) # logout the :admin user
You can keep each user’s data separate by using the Authenticated Session Data feature.