Sha256: 8c8af4edff62f02c9eb8e3e325290068ed60849451304f03d04c97245602f64f

Contents?: true

Size: 977 Bytes

Versions: 11

Compression:

Stored size: 977 Bytes

Contents

require 'doorkeeper/orm/mongoid3/concerns/scopes'

module Doorkeeper
  class AccessToken
    include Mongoid::Document
    include Mongoid::Timestamps

    include AccessTokenMixin
    include Models::Mongoid3::Scopes

    self.store_in collection: :oauth_access_tokens

    field :resource_owner_id, type: Moped::BSON::ObjectId
    field :application_id, type: Moped::BSON::ObjectId
    field :token, type: String
    field :refresh_token, type: String
    field :expires_in, type: Integer
    field :revoked_at, type: DateTime

    index({ token: 1 }, { unique: true })
    index({ refresh_token: 1 }, { 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

11 entries across 11 versions & 1 rubygems

Version Path
doorkeeper-2.2.2 lib/doorkeeper/orm/mongoid3/access_token.rb
doorkeeper-2.2.1 lib/doorkeeper/orm/mongoid3/access_token.rb
doorkeeper-2.2.0 lib/doorkeeper/orm/mongoid3/access_token.rb
doorkeeper-2.1.4 lib/doorkeeper/orm/mongoid3/access_token.rb
doorkeeper-2.1.3 lib/doorkeeper/orm/mongoid3/access_token.rb
doorkeeper-2.1.2 lib/doorkeeper/orm/mongoid3/access_token.rb
doorkeeper-2.1.1 lib/doorkeeper/orm/mongoid3/access_token.rb
doorkeeper-2.1.0 lib/doorkeeper/orm/mongoid3/access_token.rb
doorkeeper-2.0.1 lib/doorkeeper/orm/mongoid3/access_token.rb
doorkeeper-2.0.0 lib/doorkeeper/orm/mongoid3/access_token.rb
doorkeeper-2.0.0.rc3 lib/doorkeeper/orm/mongoid3/access_token.rb