Class: Oauth2Provider::OauthAuthorization
- Inherits:
-
Object
- Object
- Oauth2Provider::OauthAuthorization
- Includes:
- Mongoid::Document, Mongoid::Timestamps
- Defined in:
- app/models/oauth2_provider/oauth_authorization.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.
- .where_code_and_client_uri(code, client_id) ⇒ Object
Instance Method Summary collapse
-
#block! ⇒ Object
Block the authorization (when resource owner blocks a client).
-
#blocked? ⇒ Boolean
Check if the status is or is not blocked.
-
#expired? ⇒ Boolean
Check if the authorization is expired.
Class Method Details
.block_access!(client_uri, resource_owner_uri) ⇒ Object
Block tokens used from a client in behalf of a resource owner
34 35 36 |
# File 'app/models/oauth2_provider/oauth_authorization.rb', line 34 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
29 30 31 |
# File 'app/models/oauth2_provider/oauth_authorization.rb', line 29 def self.block_client!(client_uri) self.where(client_uri: client_uri).map(&:block!) end |
.where_code_and_client_uri(code, client_id) ⇒ Object
51 52 53 |
# File 'app/models/oauth2_provider/oauth_authorization.rb', line 51 def where_code_and_client_uri(code, client_id) where(code: code).where(client_uri: client_id) end |
Instance Method Details
#block! ⇒ Object
Block the authorization (when resource owner blocks a client)
23 24 25 26 |
# File 'app/models/oauth2_provider/oauth_authorization.rb', line 23 def block! self.blocked = Time.now self.save end |
#blocked? ⇒ Boolean
Check if the status is or is not blocked
39 40 41 |
# File 'app/models/oauth2_provider/oauth_authorization.rb', line 39 def blocked? !self.blocked.nil? end |
#expired? ⇒ Boolean
Check if the authorization is expired
44 45 46 |
# File 'app/models/oauth2_provider/oauth_authorization.rb', line 44 def expired? self.expire_at < Time.now end |