Skip to content
Brooks Swinnerton edited this page Sep 16, 2015 · 3 revisions

Warden is all about authenticating requests. There’s two sides of that.

  1. The requester (user)
  2. The application

Accessing a user

To access the user, simply call user on the auth object.

env['warden'].user # provides the currently logged in user

If you’re using a scoped authentication (scopes) you need to tell it which scoped user you would like:

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

Setting the User

The act of authentication will set the user when successful. Sometimes you may want to set the user manually.

env['warden'].set_user(@user)

Or if using scopes

env['warden'].set_user(@user, :scope => :admin)

You can also set store to false to set the user for that request, but do not store it in session

env['warden'].set_user(@user, :store => false)
Clone this wiki locally