Class: Workarea::User::AuthenticationToken
- Inherits:
-
Object
- Object
- Workarea::User::AuthenticationToken
- Includes:
- ApplicationDocument, UrlToken
- Defined in:
- app/models/workarea/user/authentication_token.rb
Class Method Summary collapse
- .authenticate(token, options = {}) ⇒ Object
- .expires_at ⇒ Object
- .refresh!(token, options = {}) ⇒ Object
Instance Method Summary collapse
Class Method Details
.authenticate(token, options = {}) ⇒ Object
15 16 17 18 19 |
# File 'app/models/workarea/user/authentication_token.rb', line 15 def self.authenticate(token, = {}) result = where(token: token).first return if result.try(:expired?) result end |
.expires_at ⇒ Object
11 12 13 |
# File 'app/models/workarea/user/authentication_token.rb', line 11 def self.expires_at Time.now + Workarea.config.authentication_token_expiration end |
.refresh!(token, options = {}) ⇒ Object
21 22 23 24 25 26 |
# File 'app/models/workarea/user/authentication_token.rb', line 21 def self.refresh!(token, = {}) result = where(token: token).first return if result.try(:expired?) return unless result.update_attribute(:expires_at, expires_at) result end |
Instance Method Details
#expired? ⇒ Boolean
28 29 30 |
# File 'app/models/workarea/user/authentication_token.rb', line 28 def expired? expires_at <= Time.now end |