about summary refs log tree commit diff
path: root/app/controllers/concerns/two_factor_authentication_concern.rb
diff options
context:
space:
mode:
authorClaire <claire.github-309c@sitedethib.com>2021-06-23 10:46:24 +0200
committerClaire <claire.github-309c@sitedethib.com>2021-06-23 10:46:24 +0200
commit37fd9670a586af057d12c3f789c0701ae074314f (patch)
treecc979a0bc830a9cc0c4e0d8beb90c487578dd522 /app/controllers/concerns/two_factor_authentication_concern.rb
parenta434f370f38ac66e05000545e36d7c696f4962d0 (diff)
parent63b807cffcba0579efdf2f4ed4a2deb93af4850b (diff)
Merge branch 'main' into glitch-soc/merge-upstream
Diffstat (limited to 'app/controllers/concerns/two_factor_authentication_concern.rb')
-rw-r--r--app/controllers/concerns/two_factor_authentication_concern.rb10
1 files changed, 4 insertions, 6 deletions
diff --git a/app/controllers/concerns/two_factor_authentication_concern.rb b/app/controllers/concerns/two_factor_authentication_concern.rb
index 4800db348..d3f00a4b4 100644
--- a/app/controllers/concerns/two_factor_authentication_concern.rb
+++ b/app/controllers/concerns/two_factor_authentication_concern.rb
@@ -52,21 +52,19 @@ module TwoFactorAuthenticationConcern
     webauthn_credential = WebAuthn::Credential.from_get(user_params[:credential])
 
     if valid_webauthn_credential?(user, webauthn_credential)
-      clear_attempt_from_session
-      remember_me(user)
-      sign_in(user)
+      on_authentication_success(user, :webauthn)
       render json: { redirect_path: root_path }, status: :ok
     else
+      on_authentication_failure(user, :webauthn, :invalid_credential)
       render json: { error: t('webauthn_credentials.invalid_credential') }, status: :unprocessable_entity
     end
   end
 
   def authenticate_with_two_factor_via_otp(user)
     if valid_otp_attempt?(user)
-      clear_attempt_from_session
-      remember_me(user)
-      sign_in(user)
+      on_authentication_success(user, :otp)
     else
+      on_authentication_failure(user, :otp, :invalid_otp_token)
       flash.now[:alert] = I18n.t('users.invalid_otp_token')
       prompt_for_two_factor(user)
     end