mirror of
https://github.com/zulip/zulip.git
synced 2026-06-30 21:11:04 +08:00
auth: Change the logger for authing to the wrong subdomain situations.
It's better to use zulip.auth logger here instead of the root logger. Also the level is adjusted to INFO, since WARNING is excessive.
This commit is contained in:
parent
71f6f2310c
commit
1faebecb7a
@ -413,6 +413,8 @@ class CreateUserForm(forms.Form):
|
||||
|
||||
|
||||
class OurAuthenticationForm(AuthenticationForm):
|
||||
logger = logging.getLogger("zulip.auth.OurAuthenticationForm")
|
||||
|
||||
def clean(self) -> Dict[str, Any]:
|
||||
username = self.cleaned_data.get("username")
|
||||
password = self.cleaned_data.get("password")
|
||||
@ -459,7 +461,7 @@ class OurAuthenticationForm(AuthenticationForm):
|
||||
raise ValidationError(error_message)
|
||||
|
||||
if return_data.get("invalid_subdomain"):
|
||||
logging.warning(
|
||||
self.logger.info(
|
||||
"User attempted password login to wrong subdomain %s. Matching accounts: %s",
|
||||
subdomain,
|
||||
return_data.get("matching_user_ids_in_different_realms"),
|
||||
|
||||
@ -823,13 +823,13 @@ class LoginTest(ZulipTestCase):
|
||||
def test_login_wrong_subdomain(self) -> None:
|
||||
user_profile = self.mit_user("sipbtest")
|
||||
email = user_profile.delivery_email
|
||||
with self.assertLogs(level="WARNING") as m:
|
||||
with self.assertLogs("zulip.auth.OurAuthenticationForm", level="INFO") as m:
|
||||
result = self.login_with_return(email, "xxx")
|
||||
matching_accounts_dict = {"realm_id": user_profile.realm_id, "id": user_profile.id}
|
||||
self.assertEqual(
|
||||
m.output,
|
||||
[
|
||||
f"WARNING:root:User attempted password login to wrong subdomain zulip. Matching accounts: [{matching_accounts_dict}]"
|
||||
f"INFO:zulip.auth.OurAuthenticationForm:User attempted password login to wrong subdomain zulip. Matching accounts: [{matching_accounts_dict}]"
|
||||
],
|
||||
)
|
||||
self.assertEqual(result.status_code, 200)
|
||||
|
||||
Loading…
Reference in New Issue
Block a user