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