Module: DoorkeeperMongodb::Mixins::Mongoid::ApplicationMixin::ClassMethods

Defined in:
lib/doorkeeper-mongodb/mixins/mongoid/application_mixin.rb

Instance Method Summary collapse

Instance Method Details

#by_uid(uid) ⇒ Doorkeeper::Application?

Returns an instance of the Doorkeeper::Application with specific UID.

Parameters:

  • uid (#to_s)

    UID (any object that responds to ‘#to_s`)

Returns:



161
162
163
# File 'lib/doorkeeper-mongodb/mixins/mongoid/application_mixin.rb', line 161

def by_uid(uid)
  where(uid: uid.to_s).first
end

#by_uid_and_secret(uid, secret) ⇒ Doorkeeper::Application?

Returns an instance of the Doorkeeper::Application with specific UID and secret.

Public/Non-confidential applications will only find by uid if secret is blank.

Parameters:

  • uid (#to_s)

    UID (any object that responds to ‘#to_s`)

  • secret (#to_s)

    secret (any object that responds to ‘#to_s`)

Returns:



145
146
147
148
149
150
151
152
# File 'lib/doorkeeper-mongodb/mixins/mongoid/application_mixin.rb', line 145

def by_uid_and_secret(uid, secret)
  app = by_uid(uid)
  return unless app
  return app if secret.blank? && !app.confidential?
  return unless app.secret_matches?(secret)

  app
end

#fallback_secret_strategyObject



169
170
171
# File 'lib/doorkeeper-mongodb/mixins/mongoid/application_mixin.rb', line 169

def fallback_secret_strategy
  ::Doorkeeper.configuration.application_secret_fallback_strategy
end

#revoke_tokens_and_grants_for(id, resource_owner) ⇒ Object

Revokes AccessToken and AccessGrant records that have not been revoked and associated with the specific Application and Resource Owner.

Parameters:

  • resource_owner (ActiveRecord::Base)

    instance of the Resource Owner model



179
180
181
182
# File 'lib/doorkeeper-mongodb/mixins/mongoid/application_mixin.rb', line 179

def revoke_tokens_and_grants_for(id, resource_owner)
  Doorkeeper::AccessToken.revoke_all_for(id, resource_owner)
  Doorkeeper::AccessGrant.revoke_all_for(id, resource_owner)
end

#secret_strategyObject



165
166
167
# File 'lib/doorkeeper-mongodb/mixins/mongoid/application_mixin.rb', line 165

def secret_strategy
  ::Doorkeeper.configuration.application_secret_strategy
end