diff options
Diffstat (limited to 'app/models/u2f_registration.rb')
-rw-r--r-- | app/models/u2f_registration.rb | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/app/models/u2f_registration.rb b/app/models/u2f_registration.rb index 1a389081913..65dc7a47533 100644 --- a/app/models/u2f_registration.rb +++ b/app/models/u2f_registration.rb @@ -4,11 +4,19 @@ class U2fRegistration < ApplicationRecord belongs_to :user - after_commit :schedule_webauthn_migration, on: :create - after_commit :update_webauthn_registration, on: :update, if: :counter_changed? - def schedule_webauthn_migration - BackgroundMigrationWorker.perform_async('MigrateU2fWebauthn', [id, id]) + after_create :create_webauthn_registration + after_update :update_webauthn_registration, if: :counter_changed? + + def create_webauthn_registration + converter = Gitlab::Auth::U2fWebauthnConverter.new(self) + WebauthnRegistration.create!(converter.convert) + rescue StandardError => ex + Gitlab::AppJsonLogger.error( + event: 'u2f_migration', + error: ex.class.name, + backtrace: ::Gitlab::BacktraceCleaner.clean_backtrace(ex.backtrace), + message: "U2F to WebAuthn conversion failed") end def update_webauthn_registration |