class CryptIdent::SessionExpired
Determine whether the Session has Expired due to User inactivity.
This class *is not* part of the published API. @private
Public Instance Methods
call(session_data)
click to toggle source
# File lib/crypt_ident/session_expired.rb, line 67 def call(session_data) # Guest sessions never expire. return false if guest_user_from?(session_data) expiry_from(session_data) <= Time.now end
Private Instance Methods
expiry_from(session_data)
click to toggle source
# File lib/crypt_ident/session_expired.rb, line 85 def expiry_from(session_data) Hanami::Utils::Kernel.Time(session_data[:expires_at].to_i) end
guest_user_from?(session_data)
click to toggle source
# File lib/crypt_ident/session_expired.rb, line 76 def guest_user_from?(session_data) user = session_data[:current_user] || UserRepository.guest_user # If the `session_data` in fact came from Rack session data, then any # objects (such as a `User` Entity) have been converted to JSON-compatible # types. Hanami Entities can be implicitly converted to and from Hashes of # their attributes, so this part's easy... User.new(user).guest? end