Class: OctopusAuth::Revoke

Inherits:
Object
  • Object
show all
Defined in:
lib/octopus_auth/revoke.rb

Instance Method Summary collapse

Constructor Details

#initialize(access_token_value) ⇒ Revoke

Returns a new instance of Revoke.



3
4
5
6
7
8
9
# File 'lib/octopus_auth/revoke.rb', line 3

def initialize(access_token_value)
  @access_token = OctopusAuth.configuration.model_class.find_by(token: access_token_value)

  unless @access_token
    raise OctopusAuth::Errors::TokenNotFoundError.new("API Access token #{access_token_value} is not found")
  end
end

Instance Method Details

#executeObject



11
12
13
14
15
16
17
18
# File 'lib/octopus_auth/revoke.rb', line 11

def execute
  @access_token.expired_at = Time.now.utc
  @access_token.active = false

  @access_token.save!

  OctopusAuth::Decorators::Default.new(@access_token)
end