Sha256: 7ba642acd5f9f2cb65d41619a7baf2469a50f476334dfa6f3edbd3e1189d8e45

Contents?: true

Size: 709 Bytes

Versions: 4

Compression:

Stored size: 709 Bytes

Contents

module Doorkeeper
  module Models
    module Revocable
      def revoke(clock = Time)
        update_attribute :revoked_at, clock.now.utc
      end

      def revoked?
        !!(revoked_at && revoked_at <= Time.now.utc)
      end

      def revoke_previous_refresh_token!
        return unless refresh_token_revoked_on_use?
        old_refresh_token.revoke if old_refresh_token
        update_attribute :previous_refresh_token, ""
      end

      private

      def old_refresh_token
        @old_refresh_token ||=
          AccessToken.by_refresh_token(previous_refresh_token)
      end

      def refresh_token_revoked_on_use?
        AccessToken.refresh_token_revoked_on_use?
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
doorkeeper-4.2.0 lib/doorkeeper/models/concerns/revocable.rb
doorkeeper-4.1.0 lib/doorkeeper/models/concerns/revocable.rb
doorkeeper-4.0.0 lib/doorkeeper/models/concerns/revocable.rb
doorkeeper-4.0.0.rc4 lib/doorkeeper/models/concerns/revocable.rb