FIX: enforce second factor with subfolders (#30992)
fix an improper redirect when enforcing second factor under a subfolder install
This commit is contained in:
parent
59a6775848
commit
4c1c4ba8d4
|
@ -893,7 +893,7 @@ class ApplicationController < ActionController::Base
|
|||
|
||||
redirect_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_path
|
||||
nil
|
||||
end
|
||||
end
|
||||
|
|
|
@ -142,6 +142,15 @@ RSpec.describe ApplicationController do
|
|||
expect(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'" do
|
||||
SiteSetting.enforce_second_factor = "all"
|
||||
sign_in(user)
|
||||
|
|
Loading…
Reference in New Issue