From 9c3cefa2b1a30515a106998bd0304ca4706be33e Mon Sep 17 00:00:00 2001 From: baarkerlounger Date: Thu, 23 Jun 2022 12:53:56 +0100 Subject: [PATCH] Remove 2FA success flash message --- .../auth/two_factor_authentication_controller.rb | 9 +++++++++ spec/features/user_spec.rb | 1 - 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/app/controllers/auth/two_factor_authentication_controller.rb b/app/controllers/auth/two_factor_authentication_controller.rb index 730f3dec5..ee21eacf1 100644 --- a/app/controllers/auth/two_factor_authentication_controller.rb +++ b/app/controllers/auth/two_factor_authentication_controller.rb @@ -23,6 +23,15 @@ private end end + def after_two_factor_success_for(resource) + set_remember_two_factor_cookie(resource) + warden.session(resource_name)[TwoFactorAuthentication::NEED_AUTHENTICATION] = false + bypass_sign_in(resource, scope: resource_name) + resource.update_attribute(:second_factor_attempts_count, 0) + + redirect_to after_two_factor_success_path_for(resource) + end + def after_two_factor_success_path_for(resource) if resource.is_a?(User) && resource.support? "/organisations" diff --git a/spec/features/user_spec.rb b/spec/features/user_spec.rb index 566cdaa34..61f3ce024 100644 --- a/spec/features/user_spec.rb +++ b/spec/features/user_spec.rb @@ -503,7 +503,6 @@ RSpec.describe "User Features" do fill_in("code", with: otp) click_button("Submit") expect(page).to have_content("Logs") - expect(page).to have_content(I18n.t("devise.two_factor_authentication.success")) end context "but it is more than 15 minutes old" do