Class: Sso::Warden::Hooks::BeforeLogout

Inherits:
Object
  • Object
show all
Includes:
Logging
Defined in:
lib/sso/warden/hooks/before_logout.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Logging

#debug, #error, #fatal, #info, #warn

Constructor Details

#initialize(user, warden, options) ⇒ BeforeLogout

Returns a new instance of BeforeLogout.



17
18
19
# File 'lib/sso/warden/hooks/before_logout.rb', line 17

def initialize(user, warden, options)
  @user, @warden, @options = user, warden, options
end

Instance Attribute Details

#optionsObject (readonly)

Returns the value of attribute options.



7
8
9
# File 'lib/sso/warden/hooks/before_logout.rb', line 7

def options
  @options
end

#userObject (readonly)

Returns the value of attribute user.



7
8
9
# File 'lib/sso/warden/hooks/before_logout.rb', line 7

def user
  @user
end

#wardenObject (readonly)

Returns the value of attribute warden.



7
8
9
# File 'lib/sso/warden/hooks/before_logout.rb', line 7

def warden
  @warden
end

Class Method Details

.to_procObject



11
12
13
14
15
# File 'lib/sso/warden/hooks/before_logout.rb', line 11

def self.to_proc
  proc do |user, warden, options|
    new(user, warden, options).call
  end
end

Instance Method Details

#callObject



21
22
23
24
25
26
27
28
# File 'lib/sso/warden/hooks/before_logout.rb', line 21

def call
  # Only run if user is logged in
  if logged_in?
    debug { "#BeforeLogout Sso::Session - #{session["sso_session_id"]}" }
    debug { "user is #{user.inspect}" }
    ::Sso::Session.logout(session["sso_session_id"])
  end
end

#logged_in?Boolean

Returns:

  • (Boolean)


38
39
40
# File 'lib/sso/warden/hooks/before_logout.rb', line 38

def logged_in?
  warden.authenticated?(scope) && session && user
end

#scopeObject



30
31
32
# File 'lib/sso/warden/hooks/before_logout.rb', line 30

def scope
  scope = options[:scope]
end

#sessionObject



34
35
36
# File 'lib/sso/warden/hooks/before_logout.rb', line 34

def session
  warden.session(scope)
end