Module: Tokenable::Verifier

Extended by:
ActiveSupport::Concern
Defined in:
lib/tokenable/verifier.rb

Instance Method Summary collapse

Instance Method Details

#current_verifierObject



13
14
15
# File 'lib/tokenable/verifier.rb', line 13

def current_verifier
  read_attribute(verifier_key) || issue_verifier!
end

#invalidate_tokens!Object



17
18
19
# File 'lib/tokenable/verifier.rb', line 17

def invalidate_tokens!
  issue_verifier!
end

#issue_verifier!Object



21
22
23
24
# File 'lib/tokenable/verifier.rb', line 21

def issue_verifier!
  update!(verifier_key => SecureRandom.uuid)
  read_attribute(verifier_key)
end

#valid_verifier?(verifier) ⇒ Boolean

Returns:

  • (Boolean)

Raises:



7
8
9
10
11
# File 'lib/tokenable/verifier.rb', line 7

def valid_verifier?(verifier)
  raise Tokenable::Unauthorized, "#{verifier_key} field is missing" unless has_attribute?(verifier_key)

  current_verifier == verifier
end