class SSO::Server::Warden::Hooks::AfterAuthentication
Attributes
options[R]
user[R]
warden[R]
Public Class Methods
new(user:, warden:, options:)
click to toggle source
# File lib/sso/server/warden/hooks/after_authentication.rb, line 21 def initialize(user:, warden:, options:) @user, @warden, @options = user, warden, options end
to_proc()
click to toggle source
# File lib/sso/server/warden/hooks/after_authentication.rb, line 10 def self.to_proc proc do |user, warden, options| begin new(user: user, warden: warden, options: options).call rescue => exception ::SSO.config.exception_handler.call exception # The show must go on end end end
Public Instance Methods
call()
click to toggle source
# File lib/sso/server/warden/hooks/after_authentication.rb, line 25 def call debug { 'Starting hook because this is considered the first login of the current session...' } request = warden.request session = warden.env['rack.session'] debug { "Generating a passport for user #{user.id.inspect} for the session with the SSO server..." } attributes = { owner_id: user.id, ip: request.ip, agent: request.user_agent } generation = SSO::Server::Passports.generate attributes if generation.success? debug { "Passport with ID #{generation.object.inspect} generated successfuly. Persisting it in session..." } session[:passport_id] = generation.object else fail generation.code.inspect + generation.object.inspect end debug { 'Finished.' } end