Class: Sso::Warden::Hooks::SessionCheck
- Inherits:
-
Object
- Object
- Sso::Warden::Hooks::SessionCheck
- Includes:
- Logging
- Defined in:
- lib/sso/warden/hooks/session_check.rb
Instance Attribute Summary collapse
-
#options ⇒ Object
readonly
Returns the value of attribute options.
-
#user ⇒ Object
readonly
Returns the value of attribute user.
-
#warden ⇒ Object
readonly
Returns the value of attribute warden.
Class Method Summary collapse
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(user:, warden:, options:) ⇒ SessionCheck
constructor
A new instance of SessionCheck.
- #logged_in? ⇒ Boolean
- #scope ⇒ Object
- #session ⇒ Object
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, end |
Instance Attribute Details
#options ⇒ Object (readonly)
Returns the value of attribute options.
7 8 9 |
# File 'lib/sso/warden/hooks/session_check.rb', line 7 def @options end |
#user ⇒ Object (readonly)
Returns the value of attribute user.
7 8 9 |
# File 'lib/sso/warden/hooks/session_check.rb', line 7 def user @user end |
#warden ⇒ Object (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_proc ⇒ Object
11 12 13 14 15 |
# File 'lib/sso/warden/hooks/session_check.rb', line 11 def self.to_proc proc do |user, warden, | new(user: user, warden: warden, options: ).call end end |
Instance Method Details
#call ⇒ Object
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 Sso::Session.find_by(id: session["sso_session_id"]).try(:active?) warden.logout(:user) throw(:warden, :scope => scope, :reason => "Sso::Session not found") end end |
#logged_in? ⇒ Boolean
39 40 41 |
# File 'lib/sso/warden/hooks/session_check.rb', line 39 def logged_in? warden.authenticated?(:user) && session end |
#scope ⇒ Object
31 32 33 |
# File 'lib/sso/warden/hooks/session_check.rb', line 31 def scope scope = [:scope] end |
#session ⇒ Object
35 36 37 |
# File 'lib/sso/warden/hooks/session_check.rb', line 35 def session warden.session(scope) end |