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, BaseMixin
- 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.
229 230 231 |
# File 'lib/doorkeeper-mongodb/mixins/mongoid/access_token_mixin.rb', line 229 def acceptable?(scopes) accessible? && includes_scope?(*scopes) end |
#as_json(_options = {}) ⇒ Hash
JSON representation of the Access Token instance.
200 201 202 203 204 205 206 207 208 |
# File 'lib/doorkeeper-mongodb/mixins/mongoid/access_token_mixin.rb', line 200 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.
217 218 219 220 |
# File 'lib/doorkeeper-mongodb/mixins/mongoid/access_token_mixin.rb', line 217 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.
188 189 190 |
# File 'lib/doorkeeper-mongodb/mixins/mongoid/access_token_mixin.rb', line 188 def token_type 'bearer' end |
#use_refresh_token? ⇒ Boolean
192 193 194 195 |
# File 'lib/doorkeeper-mongodb/mixins/mongoid/access_token_mixin.rb', line 192 def use_refresh_token? @use_refresh_token ||= false !!@use_refresh_token end |