mirror of
https://github.com/System-End/identity-vault.git
synced 2026-04-19 22:05:07 +00:00
* add premailer * first pass at converting existing mailers * this EIN is not yours :-P * remove some css that probably won't work * that was gonna bug me * more mailers! * s/account/auth * rework 2fa/security mailers * env vars for SES creds * add OpenSSL explicitly * use external logo image * nuke step_up_code
33 lines
712 B
Ruby
33 lines
712 B
Ruby
class Identity::BackupCode < ApplicationRecord
|
|
has_paper_trail
|
|
|
|
has_secure_password :code
|
|
|
|
include AASM
|
|
|
|
belongs_to :identity
|
|
|
|
validates :code_digest, presence: true
|
|
|
|
aasm do
|
|
state :previewed, initial: true
|
|
state :active
|
|
state :used
|
|
state :discarded
|
|
|
|
event :mark_active do
|
|
transitions from: :previewed, to: :active
|
|
end
|
|
event :mark_used do
|
|
transitions from: :active, to: :used
|
|
|
|
after do
|
|
identity.create_activity :use_backup_code, owner: identity, recipient: identity
|
|
IdentityBackupCodeMailer.code_used(identity).deliver_later
|
|
end
|
|
end
|
|
event :mark_discarded do
|
|
transitions from: :active, to: :discarded
|
|
end
|
|
end
|
|
end
|