Class: Oauth2Provider::OauthToken
- Inherits:
-
Object
- Object
- Oauth2Provider::OauthToken
- Includes:
- Mongoid::Document, Mongoid::Timestamps
- Defined in:
- app/models/oauth2_provider/oauth_token.rb
Class Method Summary collapse
-
.block_access!(client_uri, resource_owner_uri) ⇒ Object
Block tokens used from a client in behalf of a resource owner.
-
.block_client!(client_uri) ⇒ Object
Block tokens used from a client.
- .exist(client_uri, resource_owner_uri, scope) ⇒ Object
Instance Method Summary collapse
-
#block! ⇒ Object
Block the resource owner delegation to a specific client.
-
#blocked? ⇒ Boolean
Check if the status is or is not blocked.
-
#expired? ⇒ Boolean
Token is expired or not.
-
#last_access ⇒ Object
Last time the resource owner have used the token.
Class Method Details
.block_access!(client_uri, resource_owner_uri) ⇒ Object
Block tokens used from a client in behalf of a resource owner
37 38 39 |
# File 'app/models/oauth2_provider/oauth_token.rb', line 37 def self.block_access!(client_uri, resource_owner_uri) self.where(client_uri: client_uri, resource_owner_uri: resource_owner_uri).map(&:block!) end |
.block_client!(client_uri) ⇒ Object
Block tokens used from a client
32 33 34 |
# File 'app/models/oauth2_provider/oauth_token.rb', line 32 def self.block_client!(client_uri) self.where(client_uri: client_uri).map(&:block!) end |
.exist(client_uri, resource_owner_uri, scope) ⇒ Object
41 42 43 44 45 |
# File 'app/models/oauth2_provider/oauth_token.rb', line 41 def self.exist(client_uri, resource_owner_uri, scope) self.where(client_uri: client_uri). where(resource_owner_uri: resource_owner_uri). all_in(scope: scope) end |
Instance Method Details
#block! ⇒ Object
Block the resource owner delegation to a specific client
26 27 28 29 |
# File 'app/models/oauth2_provider/oauth_token.rb', line 26 def block! self.blocked = Time.now self.save end |
#blocked? ⇒ Boolean
Check if the status is or is not blocked
48 49 50 |
# File 'app/models/oauth2_provider/oauth_token.rb', line 48 def blocked? !self.blocked.nil? end |
#expired? ⇒ Boolean
Token is expired or not
58 59 60 |
# File 'app/models/oauth2_provider/oauth_token.rb', line 58 def expired? self.expire_at < Time.now end |
#last_access ⇒ Object
Last time the resource owner have used the token
53 54 55 |
# File 'app/models/oauth2_provider/oauth_token.rb', line 53 def last_access self.updated_at end |