Class: HasSecurePasskey::Recovery
- Inherits:
-
Object
- Object
- HasSecurePasskey::Recovery
- Defined in:
- lib/has_secure_passkey/recovery.rb
Instance Method Summary collapse
-
#initialize(model:, params:) ⇒ Recovery
constructor
A new instance of Recovery.
- #run ⇒ Object
Constructor Details
#initialize(model:, params:) ⇒ Recovery
2 3 4 5 |
# File 'lib/has_secure_passkey/recovery.rb', line 2 def initialize(model:, params:) @model = model @params = params end |
Instance Method Details
#run ⇒ Object
7 8 9 10 11 12 13 14 15 16 |
# File 'lib/has_secure_passkey/recovery.rb', line 7 def run old_passkeys = authenticatable.passkeys.to_a ActiveRecord::Base.transaction do (authenticatable.update(webauthn_id:) && authenticatable.add_passkey(params:) && old_passkeys.all?(&:destroy) && authenticatable) || raise(ActiveRecord::Rollback) end end |