Skip to content
hassox edited this page Sep 13, 2010 · 11 revisions

Warden allows for multiple users to be logged in at the same time. This should be used very cautiously. Think, sudo access, or a publisher checking what viewing it as another user will look like, or a secured authentication step for checkout.

By default the scope is :default. The :default scope is used whenever no scope is stated.

Using Scopes

A scope is identified by an object. (I would use a symbol usually)

Authenticating


env['warden'].authenticated?(:scope => :sudo)
env['warden'].authenticated?(:pgp, :scope => :sudo)

# The same options are available for #authenticate and #authenticate!

Scoped User Access


env['warden'].user(:sudo)

Logout


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

Keeping Each Users Data Separate

You can keep each users data separate by using the Authenticated Session Data feature.

Clone this wiki locally