Class: Authorio::Token
- Inherits:
-
ApplicationRecord
- Object
- ActiveRecord::Base
- ApplicationRecord
- Authorio::Token
- Defined in:
- app/models/authorio/token.rb
Class Method Summary collapse
- .create_from_request(req) ⇒ Object
-
.find_by_auth_token(token) ⇒ Object
The token endpoint can get hit by bots, so short-circut the find if they don’t send a bearer token.
Instance Method Summary collapse
Class Method Details
.create_from_request(req) ⇒ Object
24 25 26 27 28 |
# File 'app/models/authorio/token.rb', line 24 def self.create_from_request(req) raise Exceptions::InvalidGrant, 'missing scope' if req.scope.blank? Token.create(authorio_user: req., scope: req.scope, client: req.client) end |
.find_by_auth_token(token) ⇒ Object
The token endpoint can get hit by bots, so short-circut the find if they don’t send a bearer token
16 17 18 |
# File 'app/models/authorio/token.rb', line 16 def self.find_by_auth_token(token) token and find_by auth_token: token end |
Instance Method Details
#expired? ⇒ Boolean
20 21 22 |
# File 'app/models/authorio/token.rb', line 20 def expired? expires_at < Time.now end |