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.
Instance Attribute Summary collapse
-
#token ⇒ Object
save the token in memory so we can put it in emails but only save the hashed version in the database.
Instance Method Summary collapse
- #authenticate(token) ⇒ Object
- #available? ⇒ Boolean
- #claim! ⇒ Object
- #claimed? ⇒ Boolean
- #expired? ⇒ Boolean
- #timed_out? ⇒ Boolean
- #to_param ⇒ Object
Instance Attribute Details
#token ⇒ Object
save the token in memory so we can put it in emails but only save the hashed version in the database
33 34 35 |
# File 'app/models/passwordless/session.rb', line 33 def token @token end |
Instance Method Details
#authenticate(token) ⇒ Object
40 41 42 |
# File 'app/models/passwordless/session.rb', line 40 def authenticate(token) token_digest == Passwordless.digest(token) end |
#available? ⇒ Boolean
61 62 63 |
# File 'app/models/passwordless/session.rb', line 61 def available? !expired? end |
#claim! ⇒ Object
52 53 54 55 |
# File 'app/models/passwordless/session.rb', line 52 def claim! raise Errors::TokenAlreadyClaimedError if claimed? touch(:claimed_at) end |
#claimed? ⇒ Boolean
57 58 59 |
# File 'app/models/passwordless/session.rb', line 57 def claimed? !!claimed_at end |
#expired? ⇒ Boolean
44 45 46 |
# File 'app/models/passwordless/session.rb', line 44 def expired? expires_at <= Time.current end |
#timed_out? ⇒ Boolean
48 49 50 |
# File 'app/models/passwordless/session.rb', line 48 def timed_out? timeout_at <= Time.current end |
#to_param ⇒ Object
65 66 67 |
# File 'app/models/passwordless/session.rb', line 65 def to_param identifier end |