module Padrino::Warden::Helpers
Public Class Methods
registered(app)
click to toggle source
Register the helpers directly without the controller (useful for MultiApp environments)
# File lib/padrino/warden/helpers.rb, line 58 def self.registered(app) Padrino::Warden.registered(app, false) end
Public Instance Methods
authenticate(*args)
click to toggle source
Authenticate a user against defined strategies
# File lib/padrino/warden/helpers.rb, line 23 def authenticate(*args) session[:return_to] = request.fullpath if settings.auth_use_referrer and env['REQUEST_METHOD'] == 'GET' warden.authenticate!(*args) end
Also aliased as: login
authenticated?(scope=nil)
click to toggle source
Check the current session is authenticated to a given scope
# File lib/padrino/warden/helpers.rb, line 17 def authenticated?(scope=nil) scope ? warden.authenticated?(scope) : warden.authenticated? end
Also aliased as: logged_in?
logout(scopes=nil)
click to toggle source
Terminate the current session
@param [Symbol] the session scope to terminate
# File lib/padrino/warden/helpers.rb, line 33 def logout(scopes=nil) authenticated? scopes ? warden.logout(scopes) : warden.logout end
session_info(scope=nil)
click to toggle source
Return session info
@param [Symbol] the scope to retrieve session info for
# File lib/padrino/warden/helpers.rb, line 12 def session_info(scope=nil) scope ? warden.session(scope) : scope end
user(scope=nil)
click to toggle source
Access the user from the current session
@param [Symbol] the scope for the logged in user
# File lib/padrino/warden/helpers.rb, line 41 def user(scope=nil) scope ? warden.user(scope) : warden.user end
Also aliased as: current_user
user=(new_user, opts={})
click to toggle source
Store the logged in user in the session
@param [Object] the user you want to store in the session @option opts [Symbol] :scope The scope to assign the user @example Set John as the current user
user = User.find_by_name('John')
# File lib/padrino/warden/helpers.rb, line 52 def user=(new_user, opts={}) warden.set_user(new_user, opts) end
Also aliased as: current_user=
warden()
click to toggle source
The main accessor to the warden middleware
# File lib/padrino/warden/helpers.rb, line 5 def warden request.env['warden'] end