Class: Sso::Warden::Hooks::SessionCheck

Inherits:
Object
  • Object
show all
Includes:
Logging
Defined in:
lib/sso/warden/hooks/session_check.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) ⇒ SessionCheck

Returns a new instance of SessionCheck.



17
18
19
# File 'lib/sso/warden/hooks/session_check.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/session_check.rb', line 7

def options
  @options
end

#userObject (readonly)

Returns the value of attribute user.



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

def user
  @user
end

#wardenObject (readonly)

Returns the value of attribute warden.



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

def warden
  @warden
end

Class Method Details

.to_procObject



11
12
13
14
15
# File 'lib/sso/warden/hooks/session_check.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
29
# File 'lib/sso/warden/hooks/session_check.rb', line 21

def call
  debug { "Starting hook after user is fetched into the session" }

  # Infinite loop with BeforeLogout - before logout runs this too
  unless logged_in? && Sso::Session.find_by_id(session["sso_session_id"]).try(:active?)
    warden.logout(scope)
    throw(:warden, :scope => scope, :reason => "Sso::Session INACTIVE")
  end
end

#logged_in?Boolean

Returns:

  • (Boolean)


39
40
41
# File 'lib/sso/warden/hooks/session_check.rb', line 39

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

#scopeObject



31
32
33
# File 'lib/sso/warden/hooks/session_check.rb', line 31

def scope
  scope = options[:scope]
end

#sessionObject



35
36
37
# File 'lib/sso/warden/hooks/session_check.rb', line 35

def session
  warden.session(scope)
end