Class: StandardId::CodeChallenge
- Inherits:
-
ApplicationRecord
- Object
- ActiveRecord::Base
- ApplicationRecord
- StandardId::CodeChallenge
- Defined in:
- app/models/standard_id/code_challenge.rb
Constant Summary collapse
- REALMS =
Well-known realms used by the engine itself. Host apps may create challenges in any realm (see StandardId::Otp) — realm is a free-form string that partitions challenges by purpose (e.g. “authentication”, “verification”, “custom_widget”). Only presence is validated so consumers can define their own realms without the engine knowing.
%w[authentication verification].freeze
- CHANNELS =
%w[email sms].freeze
Instance Method Summary collapse
Instance Method Details
#active? ⇒ Boolean
31 32 33 |
# File 'app/models/standard_id/code_challenge.rb', line 31 def active? !expired? && !used? end |
#expired? ⇒ Boolean
23 24 25 |
# File 'app/models/standard_id/code_challenge.rb', line 23 def expired? expires_at <= Time.current end |
#use! ⇒ Object
35 36 37 |
# File 'app/models/standard_id/code_challenge.rb', line 35 def use! update!(used_at: Time.current) end |
#used? ⇒ Boolean
27 28 29 |
# File 'app/models/standard_id/code_challenge.rb', line 27 def used? used_at.present? end |