Module: DoorkeeperMongodb::Mixins::MongoMapper::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/mongo_mapper/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.
219 220 221 |
# File 'lib/doorkeeper-mongodb/mixins/mongo_mapper/access_token_mixin.rb', line 219 def acceptable?(scopes) accessible? && includes_scope?(*scopes) end |
#as_json(_options = {}) ⇒ Hash
JSON representation of the Access Token instance.
190 191 192 193 194 195 196 197 198 |
# File 'lib/doorkeeper-mongodb/mixins/mongo_mapper/access_token_mixin.rb', line 190 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.
207 208 209 210 |
# File 'lib/doorkeeper-mongodb/mixins/mongo_mapper/access_token_mixin.rb', line 207 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.
178 179 180 |
# File 'lib/doorkeeper-mongodb/mixins/mongo_mapper/access_token_mixin.rb', line 178 def token_type 'bearer' end |
#use_refresh_token? ⇒ Boolean
182 183 184 185 |
# File 'lib/doorkeeper-mongodb/mixins/mongo_mapper/access_token_mixin.rb', line 182 def use_refresh_token? @use_refresh_token ||= false !!@use_refresh_token end |