auth: Include user-input email in some error messages in the login form.

Fixes #13126.
This commit is contained in:
Mateusz Mandera
2021-08-23 15:14:05 +02:00
committed by Tim Abbott
parent fb3864ea3c
commit c5806d9728
7 changed files with 63 additions and 23 deletions

View File

@@ -49,12 +49,12 @@ MIT_VALIDATION_ERROR = (
+ '<a href="mailto:support@zulip.com">contact us</a>.'
)
WRONG_SUBDOMAIN_ERROR = (
"Your Zulip account is not a member of the "
"Your Zulip account {username} is not a member of the "
+ "organization associated with this subdomain. "
+ "Please contact your organization administrator with any questions."
)
DEACTIVATED_ACCOUNT_ERROR = (
"Your account is no longer active. "
"Your account {username} is no longer active. "
+ "Please contact your organization administrator to reactivate it."
)
PASSWORD_RESET_NEEDED_ERROR = (
@@ -432,13 +432,15 @@ class OurAuthenticationForm(AuthenticationForm):
# We exclude mirror dummy accounts here. They should be treated as the
# user never having had an account, so we let them fall through to the
# normal invalid_login case below.
raise ValidationError(mark_safe(DEACTIVATED_ACCOUNT_ERROR))
error_message = DEACTIVATED_ACCOUNT_ERROR.format(username=username)
raise ValidationError(mark_safe(error_message))
if return_data.get("invalid_subdomain"):
logging.warning(
"User %s attempted password login to wrong subdomain %s", username, subdomain
)
raise ValidationError(mark_safe(WRONG_SUBDOMAIN_ERROR))
error_message = WRONG_SUBDOMAIN_ERROR.format(username=username)
raise ValidationError(mark_safe(error_message))
if self.user_cache is None:
raise forms.ValidationError(