Module: Doorkeeper::Orm::ActiveRecord::Mixins::Application::ClassMethods

Defined in:
lib/doorkeeper/orm/active_record/mixins/application.rb

Instance Method Summary collapse

Instance Method Details

#authorized_for(resource_owner) ⇒ ActiveRecord::Relation

Returns Applications associated with active (not revoked) Access Tokens that are owned by the specific Resource Owner.

Parameters:

  • resource_owner (ActiveRecord::Base)

    Resource Owner model instance

Returns:

  • (ActiveRecord::Relation)

    Applications authorized for the Resource Owner


173
174
175
176
# File 'lib/doorkeeper/orm/active_record/mixins/application.rb', line 173

def authorized_for(resource_owner)
  resource_access_tokens = Doorkeeper.config.access_token_model.active_for(resource_owner)
  where(id: resource_access_tokens.select(:application_id).distinct)
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


184
185
186
187
# File 'lib/doorkeeper/orm/active_record/mixins/application.rb', line 184

def revoke_tokens_and_grants_for(id, resource_owner)
  Doorkeeper.config.access_token_model.revoke_all_for(id, resource_owner)
  Doorkeeper.config.access_grant_model.revoke_all_for(id, resource_owner)
end