lib/doorkeeper-mongodb/mixins/mongoid/access_token_mixin.rb
# Looking for not expired AccessToken record with a matching set of
# scopes that belongs to specific Application and Resource Owner.
# If it doesn't exists - then creates it.
#
# @param application [Doorkeeper::Application]
#   Application instance
# @param resource_owner [Mongoid::Document, Integer]
#   Resource Owner model instance or it's ID
# @param scopes [#to_s]
#   set of scopes (any object that responds to `#to_s`)
# @param expires_in [Integer]
#   token lifetime in seconds
# @param use_refresh_token [Boolean]
#   whether to use the refresh token
#
# @return [Doorkeeper::AccessToken] existing record or a new one
#
Looking for not expired AccessToken record with a matching set of
scopes that belongs to specific Application and Resource Owner.
If it doesn't exists - then creates it.
Looking for not expired AccessToken record with a matching set of scopes that belongs to specific Application and Resource Owner . If it doesn ' t exists - then creates it .
def find_or_create_for(*args)
            attributes = if args.size > 1
                           {
                             application: args[0],
                             resource_owner: args[1],
                             scopes: args[2],
                             expires_in: args[3],
                             use_refresh_token: args[4],
                           }
                         else
                           args.first
                         end
            application = attributes[:application]
            resource_owner = attributes[:resource_owner]
            scopes = attributes[:scopes]
            expires_in = attributes[:expires_in]
            use_refresh_token = attributes[:use_refresh_token]
            if Doorkeeper.configuration.reuse_access_token
              access_token = matching_token_for(application, resource_owner, scopes)
              return access_token if access_token&.reusable?
            end
            create_for(
              application: application,
              resource_owner: resource_owner,
              scopes: scopes,
              expires_in: expires_in,
              use_refresh_token: use_refresh_token,
            )
          end
def find_or_create_for ( * args ) attributes = if args . size > 1 { application : args [ 0 ] , resource_owner : args [ 1 ] , scopes : args [ 2 ] , expires_in : args [ 3 ] , use_refresh_token : args [ 4 ] , } else args . first end application = attributes [ :application ] resource_owner = attributes [ :resource_owner ] scopes = attributes [ :scopes ] expires_in = attributes [ :expires_in ] use_refresh_token = attributes [ :use_refresh_token ] if Doorkeeper . configuration . reuse_access_token access_token = matching_token_for ( application , resource_owner , scopes ) return access_token if access_token &. reusable? end create_for ( application : application , resource_owner : resource_owner , scopes : scopes , expires_in : expires_in , use_refresh_token : use_refresh_token , ) end
Looking for not expired AccessToken record with a matching set of
scopes that belongs to specific Application and Resource Owner.
Looking for not expired AccessToken record with a matching set of scopes that belongs to specific Application and Resource Owner .
# [NOTE]: For backward compatibility with Doorkeeper < 5.4
existing record or a new one
existing record or a new one
Doorkeeper::AccessToken
args
<not_specific>
application
<not_specific>
None
resource_owner
<not_specific>
Resource Owner model instance or it's ID
Resource Owner model instance or it ' s ID
scopes
<not_specific>
set of scopes (any object that responds to `#to_s`)
set of scopes ( any object that responds to ` #to_s ` )
expires_in
<not_specific>
token lifetime in seconds
token lifetime in seconds
use_refresh_token
<not_specific>
whether to use the refresh token
whether to use the refresh token