Sha256: 54e831c661932bb5bac75afc9cf401b03a616541b34f07c6c13f0eac06c92c04

Contents?: true

Size: 957 Bytes

Versions: 2

Compression:

Stored size: 957 Bytes

Contents

require 'doorkeeper/orm/mongoid2/concerns/scopes'
require 'doorkeeper-mongodb/compatible'

module Doorkeeper
  class AccessToken
    include DoorkeeperMongodb::Compatible

    include Mongoid::Document
    include Mongoid::Timestamps

    include AccessTokenMixin
    include Models::Mongoid2::Scopes

    self.store_in :oauth_access_tokens

    field :resource_owner_id, type: Integer
    field :token, type: String
    field :refresh_token, type: String
    field :expires_in, type: Integer
    field :revoked_at, type: DateTime

    index :token, unique: true
    index :refresh_token, unique: true, sparse: true

    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.order_method
      :order_by
    end

    def self.created_at_desc
      [:created_at, :desc]
    end
  end
end

Version data entries

2 entries across 2 versions & 2 rubygems

Version Path
doorkeeper-mongodb-3.0.0 lib/doorkeeper/orm/mongoid2/access_token.rb
dd-doorkeeper-mongodb-3.0.0 lib/doorkeeper/orm/mongoid2/access_token.rb