Sha256: d70ed3137ef16359da7f90c3d8cb7bac20ae37c95da7fa6d9992f7e614289864

Contents?: true

Size: 900 Bytes

Versions: 9

Compression:

Stored size: 900 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

9 entries across 3 versions & 1 rubygems

Version Path
doorkeeper-mongodb-5.0.0 lib/doorkeeper/orm/mongoid7/access_token.rb
doorkeeper-mongodb-5.0.0 lib/doorkeeper/orm/mongoid4/access_token.rb
doorkeeper-mongodb-5.0.0 lib/doorkeeper/orm/mongoid5/access_token.rb
doorkeeper-mongodb-4.2.0 lib/doorkeeper/orm/mongoid5/access_token.rb
doorkeeper-mongodb-4.2.0 lib/doorkeeper/orm/mongoid4/access_token.rb
doorkeeper-mongodb-4.2.0 lib/doorkeeper/orm/mongoid7/access_token.rb
doorkeeper-mongodb-4.1.0 lib/doorkeeper/orm/mongoid4/access_token.rb
doorkeeper-mongodb-4.1.0 lib/doorkeeper/orm/mongoid7/access_token.rb
doorkeeper-mongodb-4.1.0 lib/doorkeeper/orm/mongoid5/access_token.rb