Class: StandardId::CodeChallenge

Inherits:
ApplicationRecord show all
Defined in:
app/models/standard_id/code_challenge.rb

Constant Summary collapse

REALMS =
%w[authentication verification].freeze
CHANNELS =
%w[email sms].freeze

Instance Method Summary collapse

Instance Method Details

#active?Boolean

Returns:

  • (Boolean)


26
27
28
# File 'app/models/standard_id/code_challenge.rb', line 26

def active?
  !expired? && !used?
end

#expired?Boolean

Returns:

  • (Boolean)


18
19
20
# File 'app/models/standard_id/code_challenge.rb', line 18

def expired?
  expires_at <= Time.current
end

#use!Object



30
31
32
# File 'app/models/standard_id/code_challenge.rb', line 30

def use!
  update!(used_at: Time.current)
end

#used?Boolean

Returns:

  • (Boolean)


22
23
24
# File 'app/models/standard_id/code_challenge.rb', line 22

def used?
  used_at.present?
end