module Authstrategies::Manager
Public Class Methods
Executed every time the user is authenticated (first time in each session). Courtesy of Warden
, for more information check the warden callbacks wiki
# File lib/authstrategies.rb, line 71 def self.after_authentication &block Warden::Manager.after_authentication do |user, auth, opts| yield(user, auth, opts) end end
This is called each time after the user logs in 3 parameters are passed to this callback
>current_user - the user that hase just been set¶ ↑
>request - the request data¶ ↑
>response - the response data¶ ↑
# File lib/authstrategies.rb, line 118 def self.after_login &block self.register :after_login, &block end
This is called in the failure application Useful for redirecting the user after he logs in 2 params are passed to this callback
>request - the request data¶ ↑
>response - the response data¶ ↑
# File lib/authstrategies.rb, line 91 def self.after_login_failure &block self.register :after_login_failure, &block end
This is called after the user is logged out. Useful for redirecting the user after logging out 2 parameters are passed to this callback
>request - the request data¶ ↑
>response - the response data¶ ↑
# File lib/authstrategies.rb, line 109 def self.after_logout &block self.register :after_logout, &block end
This is called every time the user is set. The user is set:
> on each request when they are accessed for the first time via env.user¶ ↑
> when the user is initially authenticated¶ ↑
> when the user is set via the set_user method¶ ↑
Courtesy of Warden
, for more information check the warden callbacks wiki
# File lib/authstrategies.rb, line 61 def self.after_set_user &block Warden::Manager.after_set_user do |user, auth, opts| yield(user, auth, opts) end end
This is called after the user is saved into the database 3 parameters are passed to this callback
>user - the user that just signed up¶ ↑
>request - the request data¶ ↑
>response - the response data¶ ↑
Also since the user is set to session via env.set_user after_set_user
is also called after the user signs up
# File lib/authstrategies.rb, line 130 def self.after_signup &block self.register :after_signup, &block end
This callback is run right before the failure application is called. Courtesy of Warden
, for more information check the warden callbacks wiki
# File lib/authstrategies.rb, line 80 def self.before_login_failure &block Warden::Manager.before_failure do |env, opts| yield(env, opts) end end
This callback is run before each user is logged out.
Courtesy of Warden, for more information check the warden callbacks wiki
# File lib/authstrategies.rb, line 98 def self.before_logout &block Warden::Manager.before_logout do |user, auth, opts| yield(user, auth, opts) end end
# File lib/authstrategies.rb, line 42 def self.call hook, args = [] if self.registered? hook @@callbacks[hook].each do |callback| callback.call(args) end end end
# File lib/authstrategies.rb, line 50 def self.config &block yield(@@config) if block_given? @@config end
# File lib/authstrategies.rb, line 34 def self.register hook, &block if self.registered? hook @@callbacks[hook].push block else @@callbacks[hook] = [block] end end
# File lib/authstrategies.rb, line 30 def self.registered? hook @@callbacks.has_key? hook end