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
32 33 34 |
# File 'app/models/passwordless/session.rb', line 32 def token @token end |
Instance Method Details
#authenticate(token) ⇒ Object
39 40 41 |
# File 'app/models/passwordless/session.rb', line 39 def authenticate(token) token_digest == Passwordless.digest(token) end |
#available? ⇒ Boolean
60 61 62 |
# File 'app/models/passwordless/session.rb', line 60 def available? !expired? end |
#claim! ⇒ Object
51 52 53 54 |
# File 'app/models/passwordless/session.rb', line 51 def claim! raise Errors::TokenAlreadyClaimedError if claimed? touch(:claimed_at) end |
#claimed? ⇒ Boolean
56 57 58 |
# File 'app/models/passwordless/session.rb', line 56 def claimed? !!claimed_at end |
#expired? ⇒ Boolean
43 44 45 |
# File 'app/models/passwordless/session.rb', line 43 def expired? expires_at <= Time.current end |
#timed_out? ⇒ Boolean
47 48 49 |
# File 'app/models/passwordless/session.rb', line 47 def timed_out? timeout_at <= Time.current end |
#to_param ⇒ Object
64 65 66 |
# File 'app/models/passwordless/session.rb', line 64 def to_param identifier end |