auth: Retain email value if login fails.

Fixes #7795
This commit is contained in:
Umair Khan
2018-02-23 13:02:13 +05:00
committed by Tim Abbott
parent 0e8cadf980
commit 54e56481e6
2 changed files with 6 additions and 1 deletions

View File

@@ -312,7 +312,9 @@ class LoginTest(ZulipTestCase):
self.assertIsNone(get_session_dict_user(self.client.session))
def test_login_bad_password(self) -> None:
self.login(self.example_email("hamlet"), password="wrongpassword", fails=True)
email = self.example_email("hamlet")
result = self.login_with_return(email, password="wrongpassword")
self.assert_in_success_response([email], result)
self.assertIsNone(get_session_dict_user(self.client.session))
def test_login_nonexist_user(self) -> None:

View File

@@ -545,6 +545,9 @@ def login_page(request: HttpRequest, **kwargs: Any) -> HttpResponse:
# only if it actually exists.
return HttpResponseRedirect(realm.uri)
if 'username' in request.POST:
extra_context['email'] = request.POST['username']
try:
template_response = django_login_page(
request, authentication_form=OurAuthenticationForm,