Module: DoorkeeperMongodb::Mixins::Mongoid::AccessTokenMixin
- Extended by:
- ActiveSupport::Concern
- Includes:
- Doorkeeper::Models::Accessible, Doorkeeper::Models::Expirable, Doorkeeper::Models::Revocable, Doorkeeper::Models::Scopes, Doorkeeper::OAuth::Helpers
- Included in:
- Doorkeeper::AccessToken
- Defined in:
- lib/doorkeeper-mongodb/mixins/mongoid/access_token_mixin.rb
Defined Under Namespace
Modules: ClassMethods
Instance Method Summary collapse
-
#acceptable?(scopes) ⇒ Boolean
Indicates if token is acceptable for specific scopes.
-
#as_json(_options = {}) ⇒ Hash
JSON representation of the Access Token instance.
-
#same_credential?(access_token) ⇒ Boolean
Indicates whether the token instance have the same credential as the other Access Token.
-
#token_type ⇒ Object
Access Token type: Bearer.
- #use_refresh_token? ⇒ Boolean
Instance Method Details
#acceptable?(scopes) ⇒ Boolean
Indicates if token is acceptable for specific scopes.
228 229 230 |
# File 'lib/doorkeeper-mongodb/mixins/mongoid/access_token_mixin.rb', line 228 def acceptable?(scopes) accessible? && includes_scope?(*scopes) end |
#as_json(_options = {}) ⇒ Hash
JSON representation of the Access Token instance.
199 200 201 202 203 204 205 206 207 |
# File 'lib/doorkeeper-mongodb/mixins/mongoid/access_token_mixin.rb', line 199 def as_json( = {}) { resource_owner_id: resource_owner_id, scopes: scopes, expires_in_seconds: expires_in_seconds, application: {uid: application.try(:uid)}, created_at: created_at.to_i } end |
#same_credential?(access_token) ⇒ Boolean
Indicates whether the token instance have the same credential as the other Access Token.
216 217 218 219 |
# File 'lib/doorkeeper-mongodb/mixins/mongoid/access_token_mixin.rb', line 216 def same_credential?(access_token) application_id == access_token.application_id && resource_owner_id == access_token.resource_owner_id end |
#token_type ⇒ Object
Access Token type: Bearer.
187 188 189 |
# File 'lib/doorkeeper-mongodb/mixins/mongoid/access_token_mixin.rb', line 187 def token_type 'bearer' end |
#use_refresh_token? ⇒ Boolean
191 192 193 194 |
# File 'lib/doorkeeper-mongodb/mixins/mongoid/access_token_mixin.rb', line 191 def use_refresh_token? @use_refresh_token ||= false !!@use_refresh_token end |