mirror of
https://github.com/discourse/discourse.git
synced 2025-05-28 13:51:18 +08:00
FIX: Improve email validation error handling for external logins (#11307)
- Display reason for validation error when logging in via an authenticator - Fix email validation handling for 'Discourse SSO', and add a spec Previously, validation errors (e.g. blocked or already-taken emails) would raise a generic error with no useful information.
This commit is contained in:
@ -580,6 +580,22 @@ RSpec.describe SessionController do
|
||||
expect(response.body).to include(I18n.t('sso.blank_id_error'))
|
||||
end
|
||||
|
||||
it 'can handle invalid sso email validation errors' do
|
||||
SiteSetting.blocked_email_domains = "test.com"
|
||||
sso = get_sso("/")
|
||||
sso.email = "test@test.com"
|
||||
sso.external_id = '123'
|
||||
sso.username = 'sam'
|
||||
|
||||
messages = track_log_messages(level: Logger::WARN) do
|
||||
get "/session/sso_login", params: Rack::Utils.parse_query(sso.payload), headers: headers
|
||||
end
|
||||
|
||||
expect(messages.length).to eq(0)
|
||||
expect(response.status).to eq(500)
|
||||
expect(response.body).to include(I18n.t("sso.email_error", email: ERB::Util.html_escape("test@test.com")))
|
||||
end
|
||||
|
||||
it 'can handle invalid sso external ids due to banned word' do
|
||||
sso = get_sso("/")
|
||||
sso.email = "test@test.com"
|
||||
|
Reference in New Issue
Block a user