Sha256: 726780d1cb61c779ef7e343296253f8af6d5690924000d5c8214facada17c672

Contents?: true

Size: 883 Bytes

Versions: 3

Compression:

Stored size: 883 Bytes

Contents

module Doorkeeper
  class AccessToken < ActiveRecord::Base
    if Doorkeeper.configuration.active_record_options[:establish_connection]
      establish_connection Doorkeeper.configuration.active_record_options[:establish_connection]
    end

    self.table_name = "#{table_name_prefix}oauth_access_tokens#{table_name_suffix}".to_sym

    def self.delete_all_for(application_id, resource_owner)
      where(application_id: application_id,
            resource_owner_id: resource_owner.id).delete_all
    end
    private_class_method :delete_all_for

    def self.last_authorized_token_for(application_id, resource_owner_id)
      where(application_id: application_id,
            resource_owner_id: resource_owner_id,
            revoked_at: nil).
        order('created_at desc').
        limit(1).
        first
    end
    private_class_method :last_authorized_token_for
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
doorkeeper-1.4.2 lib/doorkeeper/models/active_record/access_token.rb
doorkeeper-1.4.1 lib/doorkeeper/models/active_record/access_token.rb
doorkeeper-1.4.0 lib/doorkeeper/models/active_record/access_token.rb