mirror of
https://github.com/discourse/discourse.git
synced 2024-11-25 18:30:26 -06:00
FIX: For a single authenticator, do not interrupt registration flow
Followup to 0a14b9b42a
This commit is contained in:
parent
565a967192
commit
46841888b7
@ -722,8 +722,9 @@ class ApplicationController < ActionController::Base
|
||||
session[:destination_url] = destination_url
|
||||
redirect_to path('/session/sso')
|
||||
return
|
||||
elsif !SiteSetting.enable_local_logins && Discourse.enabled_authenticators.length == 1
|
||||
# Only one authentication provider, direct straight to it
|
||||
elsif !SiteSetting.enable_local_logins && Discourse.enabled_authenticators.length == 1 && !cookies[:authentication_data]
|
||||
# Only one authentication provider, direct straight to it.
|
||||
# If authentication_data is present, then we are halfway though registration. Don't redirect offsite
|
||||
cookies[:destination_url] = destination_url
|
||||
redirect_to path("/auth/#{Discourse.enabled_authenticators.first.name}")
|
||||
else
|
||||
|
@ -44,6 +44,46 @@ RSpec.describe ApplicationController do
|
||||
get "/"
|
||||
expect(response).to redirect_to("/login")
|
||||
end
|
||||
|
||||
context "with omniauth in test mode" do
|
||||
before do
|
||||
OmniAuth.config.test_mode = true
|
||||
OmniAuth.config.add_mock(:google_oauth2,
|
||||
info: OmniAuth::AuthHash::InfoHash.new(
|
||||
email: "address@example.com",
|
||||
),
|
||||
extra: {
|
||||
raw_info: OmniAuth::AuthHash.new(
|
||||
email_verified: true,
|
||||
email: "address@example.com",
|
||||
)
|
||||
}
|
||||
)
|
||||
Rails.application.env_config["omniauth.auth"] = OmniAuth.config.mock_auth[:google_oauth2]
|
||||
end
|
||||
|
||||
after do
|
||||
Rails.application.env_config["omniauth.auth"] = OmniAuth.config.mock_auth[:google_oauth2] = nil
|
||||
OmniAuth.config.test_mode = false
|
||||
end
|
||||
|
||||
it "should not redirect to authenticator if registration in progress" do
|
||||
SiteSetting.enable_local_logins = false
|
||||
SiteSetting.enable_google_oauth2_logins = true
|
||||
|
||||
get "/"
|
||||
expect(response).to redirect_to("/auth/google_oauth2")
|
||||
|
||||
expect(cookies[:authentication_data]).to eq(nil)
|
||||
|
||||
get "/auth/google_oauth2/callback.json"
|
||||
expect(response).to redirect_to("/")
|
||||
expect(cookies[:authentication_data]).not_to eq(nil)
|
||||
|
||||
get "/"
|
||||
expect(response).to redirect_to("/login")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe '#redirect_to_second_factor_if_required' do
|
||||
|
Loading…
Reference in New Issue
Block a user