Custom errors for when Email is invalid via SSO
This commit is contained in:
parent
52d78294cc
commit
aeaf5075bf
|
@ -129,6 +129,7 @@ class SessionController < ApplicationController
|
||||||
render_sso_error(text: I18n.t("sso.not_found"), status: 500)
|
render_sso_error(text: I18n.t("sso.not_found"), status: 500)
|
||||||
end
|
end
|
||||||
rescue ActiveRecord::RecordInvalid => e
|
rescue ActiveRecord::RecordInvalid => e
|
||||||
|
|
||||||
if SiteSetting.verbose_sso_logging
|
if SiteSetting.verbose_sso_logging
|
||||||
Rails.logger.warn(<<-EOF)
|
Rails.logger.warn(<<-EOF)
|
||||||
Verbose SSO log: Record was invalid: #{e.record.class.name} #{e.record.id}\n
|
Verbose SSO log: Record was invalid: #{e.record.class.name} #{e.record.id}\n
|
||||||
|
@ -137,7 +138,17 @@ class SessionController < ApplicationController
|
||||||
#{sso.diagnostics}
|
#{sso.diagnostics}
|
||||||
EOF
|
EOF
|
||||||
end
|
end
|
||||||
render_sso_error(text: I18n.t("sso.unknown_error"), status: 500)
|
|
||||||
|
|
||||||
|
text = nil
|
||||||
|
|
||||||
|
# If there's a problem with the email we can explain that
|
||||||
|
if (e.record.is_a?(User) && e.record.errors[:email].present?)
|
||||||
|
text = e.record.email.blank? ? I18n.t("sso.no_email") : I18n.t("sso.email_error")
|
||||||
|
end
|
||||||
|
|
||||||
|
render_sso_error(text: text || I18n.t("sso.unknown_error"), status: 500)
|
||||||
|
|
||||||
rescue => e
|
rescue => e
|
||||||
message = "Failed to create or lookup user: #{e}."
|
message = "Failed to create or lookup user: #{e}."
|
||||||
message << "\n\n" << "-" * 100 << "\n\n"
|
message << "\n\n" << "-" * 100 << "\n\n"
|
||||||
|
|
|
@ -1,2 +1,5 @@
|
||||||
<h1><%= @sso_error %></h1>
|
<h1><%=t 'sso.login_error' %></h1>
|
||||||
|
|
||||||
|
<br/>
|
||||||
|
|
||||||
|
<p><%= @sso_error %></p>
|
||||||
|
|
|
@ -1544,10 +1544,13 @@ en:
|
||||||
user: 'Users'
|
user: 'Users'
|
||||||
|
|
||||||
sso:
|
sso:
|
||||||
|
login_error: "Login Error"
|
||||||
not_found: "Your account couldn't be found. Please contact the site's administrator."
|
not_found: "Your account couldn't be found. Please contact the site's administrator."
|
||||||
account_not_approved: "Your account is pending approval. You will receive an email notification when you are approved."
|
account_not_approved: "Your account is pending approval. You will receive an email notification when you are approved."
|
||||||
unknown_error: "There is a problem with your account. Please contact the site's administrator."
|
unknown_error: "There is a problem with your account. Please contact the site's administrator."
|
||||||
timeout_expired: "Account login timed out, please try logging in again."
|
timeout_expired: "Account login timed out, please try logging in again."
|
||||||
|
no_email: "No email address was provided. Please contact the site's administrator."
|
||||||
|
email_error: "An account could not be registered with that email address. Please contact the site's administrator."
|
||||||
|
|
||||||
original_poster: "Original Poster"
|
original_poster: "Original Poster"
|
||||||
most_posts: "Most Posts"
|
most_posts: "Most Posts"
|
||||||
|
|
Loading…
Reference in New Issue