From e09eedf6e75e5221e39c8ebc0761c9bb27055307 Mon Sep 17 00:00:00 2001 From: Dushan <47317567+dushan-madetech@users.noreply.github.com> Date: Tue, 24 May 2022 14:38:56 +0100 Subject: [PATCH] make organisations list page default view for support user login (#605) --- .../auth/two_factor_authentication_controller.rb | 8 ++++++++ spec/features/user_spec.rb | 10 ++++++++++ 2 files changed, 18 insertions(+) diff --git a/app/controllers/auth/two_factor_authentication_controller.rb b/app/controllers/auth/two_factor_authentication_controller.rb index 7d820f9af..730f3dec5 100644 --- a/app/controllers/auth/two_factor_authentication_controller.rb +++ b/app/controllers/auth/two_factor_authentication_controller.rb @@ -22,4 +22,12 @@ private render :show, status: :unprocessable_entity end end + + def after_two_factor_success_path_for(resource) + if resource.is_a?(User) && resource.support? + "/organisations" + else + super + end + end end diff --git a/spec/features/user_spec.rb b/spec/features/user_spec.rb index 6e197f07d..a1cfb93e4 100644 --- a/spec/features/user_spec.rb +++ b/spec/features/user_spec.rb @@ -399,6 +399,16 @@ RSpec.describe "User Features" do ) click_button("Sign in") end + + it "the admin user is redirected to the organisations list page on successful sign in" do + visit("/account/sign-in") + fill_in("user[email]", with: support_user.email) + fill_in("user[password]", with: support_user.password) + click_button("Sign in") + fill_in("code", with: otp) + click_button("Submit") + expect(page).to have_current_path("/organisations") + end end context "with a valid 2FA code" do