Sha256: 086f4bcc0ccec787e354916ea6aebb9c5c79ccdf6aed85d19fb0ccdd497f9280

Contents?: true

Size: 935 Bytes

Versions: 3

Compression:

Stored size: 935 Bytes

Contents

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

    include DoorkeeperMongodb::Compatible

    include DoorkeeperMongodb::Shared::Scopes
    include DoorkeeperMongodb::Mixins::Mongoid::AccessTokenMixin

    store_in collection: :oauth_access_tokens

    field :resource_owner_id, type: BSON::ObjectId
    field :token, type: String
    field :refresh_token, type: String
    field :previous_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.order_method
      :order_by
    end

    def self.refresh_token_revoked_on_use?
      fields.collect { |field| field[0] }.include?('previous_refresh_token')
    end

    def self.created_at_desc
      %i[created_at desc]
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
doorkeeper-mongodb-5.0.0 lib/doorkeeper/orm/mongoid6/access_token.rb
doorkeeper-mongodb-4.2.0 lib/doorkeeper/orm/mongoid6/access_token.rb
doorkeeper-mongodb-4.1.0 lib/doorkeeper/orm/mongoid6/access_token.rb