A platform for community discussion. Free, open, simple.
FIX: enforce second factor with subfolders (#30992)
Jeff Wong4c1c4ba8d42d
diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rbindex 69bb118b416..631ea3ea65a 100644--- a/app/controllers/application_controller.rb+++ b/app/controllers/application_controller.rb@@ -893,7 +893,7 @@ class ApplicationController < ActionController::Baseredirect_path = path("/u/#{current_user.encoded_username}/preferences/second-factor")if !request.fullpath.start_with?(redirect_path)- redirect_to path(redirect_path)+ redirect_to redirect_pathnilendenddiff --git a/spec/requests/application_controller_spec.rb b/spec/requests/application_controller_spec.rbindex 242c7b373f8..0bd21a53cf0 100644--- a/spec/requests/application_controller_spec.rb+++ b/spec/requests/application_controller_spec.rb@@ -142,6 +142,15 @@ RSpec.describe ApplicationController doexpect(response).to redirect_to("/u/#{admin.username}/preferences/second-factor")end+ it "should properly redirect admins when enforce_second_factor is 'all' in subfolder" do+ set_subfolder "/forum"+ SiteSetting.enforce_second_factor = "all"+ sign_in(admin)++ get "/"+ expect(response).to redirect_to("/forum/u/#{admin.username}/preferences/second-factor")+ end+it "should redirect users when enforce_second_factor is 'all'" doSiteSetting.enforce_second_factor = "all"sign_in(user)