FEATURE: Automatically redirect to authenticator when there is only one

This brings the behavior in line with native Discourse SSO. If login is required, and a user tries to visit the forum, they will be directed straight to the external login page without requiring any clicks.
This commit is contained in:
David Taylor
2019-11-13 17:28:12 +00:00
parent 3c5df82590
commit 0a14b9b42a
2 changed files with 33 additions and 0 deletions

View File

@@ -15,6 +15,35 @@ RSpec.describe ApplicationController do
get "/"
expect(response.headers["Cache-Control"]).to eq("no-cache, no-store")
end
it "should redirect to login normally" do
get "/"
expect(response).to redirect_to("/login")
end
it "should redirect to SSO if enabled" do
SiteSetting.sso_url = 'http://someurl.com'
SiteSetting.enable_sso = true
get "/"
expect(response).to redirect_to("/session/sso")
end
it "should redirect to authenticator if only one, and local logins disabled" do
# Local logins and google enabled, direct to login UI
SiteSetting.enable_google_oauth2_logins = true
get "/"
expect(response).to redirect_to("/login")
# Only google enabled, login immediately
SiteSetting.enable_local_logins = false
get "/"
expect(response).to redirect_to("/auth/google_oauth2")
# Google and GitHub enabled, direct to login UI
SiteSetting.enable_github_logins = true
get "/"
expect(response).to redirect_to("/login")
end
end
describe '#redirect_to_second_factor_if_required' do