Class: Passwordless::Session
- Inherits:
-
ApplicationRecord
- Object
- ActiveRecord::Base
- ApplicationRecord
- Passwordless::Session
- Defined in:
- app/models/passwordless/session.rb
Overview
The session responsible for holding the connection between the record trying to log in and the unique tokens.
Class Method Summary collapse
Instance Method Summary collapse
- #available? ⇒ Boolean
- #claim! ⇒ Object
- #claimed? ⇒ Boolean
- #expired? ⇒ Boolean
- #timed_out? ⇒ Boolean
Class Method Details
.valid ⇒ Object
30 31 32 |
# File 'app/models/passwordless/session.rb', line 30 def self.valid available end |
Instance Method Details
#available? ⇒ Boolean
55 56 57 |
# File 'app/models/passwordless/session.rb', line 55 def available? !expired? end |
#claim! ⇒ Object
46 47 48 49 |
# File 'app/models/passwordless/session.rb', line 46 def claim! raise Errors::TokenAlreadyClaimedError if claimed? touch(:claimed_at) end |
#claimed? ⇒ Boolean
51 52 53 |
# File 'app/models/passwordless/session.rb', line 51 def claimed? !!claimed_at end |
#expired? ⇒ Boolean
38 39 40 |
# File 'app/models/passwordless/session.rb', line 38 def expired? expires_at <= Time.current end |
#timed_out? ⇒ Boolean
42 43 44 |
# File 'app/models/passwordless/session.rb', line 42 def timed_out? timeout_at <= Time.current end |