Module: Tokenable::Verifier
- Extended by:
- ActiveSupport::Concern
- Defined in:
- lib/tokenable/verifier.rb
Instance Method Summary collapse
- #current_verifier ⇒ Object
- #invalidate_tokens! ⇒ Object
- #issue_verifier! ⇒ Object
- #valid_verifier?(verifier) ⇒ Boolean
Instance Method Details
#current_verifier ⇒ Object
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
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 |