Commit 268280df by Waheed Ahmed

Merge pull request #6908 from edx/waheed/tnl1352-fix-login-if-user-none-with-advanced-security-on

Fixed ajax login when advanced security check is on for NoneType user.
parents 2057f7db cb88c1dd
...@@ -78,6 +78,14 @@ class LoginTest(TestCase): ...@@ -78,6 +78,14 @@ class LoginTest(TestCase):
value='Email or password is incorrect') value='Email or password is incorrect')
self._assert_audit_log(mock_audit_log, 'warning', [u'Login failed', u'Unknown user email', nonexistent_email]) self._assert_audit_log(mock_audit_log, 'warning', [u'Login failed', u'Unknown user email', nonexistent_email])
@patch.dict("django.conf.settings.FEATURES", {'ADVANCED_SECURITY': True})
def test_login_fail_incorrect_email_with_advanced_security(self):
nonexistent_email = u'not_a_user@edx.org'
response, mock_audit_log = self._login_response(nonexistent_email, 'test_password')
self._assert_response(response, success=False,
value='Email or password is incorrect')
self._assert_audit_log(mock_audit_log, 'warning', [u'Login failed', u'Unknown user email', nonexistent_email])
@patch.dict("django.conf.settings.FEATURES", {'SQUELCH_PII_IN_LOGS': True}) @patch.dict("django.conf.settings.FEATURES", {'SQUELCH_PII_IN_LOGS': True})
def test_login_fail_no_user_exists_no_pii(self): def test_login_fail_no_user_exists_no_pii(self):
nonexistent_email = u'not_a_user@edx.org' nonexistent_email = u'not_a_user@edx.org'
......
...@@ -1034,7 +1034,7 @@ def login_user(request, error=""): # pylint: disable-msg=too-many-statements,un ...@@ -1034,7 +1034,7 @@ def login_user(request, error=""): # pylint: disable-msg=too-many-statements,un
}) # TODO: this should be status code 429 # pylint: disable=fixme }) # TODO: this should be status code 429 # pylint: disable=fixme
# see if the user must reset his/her password due to any policy settings # see if the user must reset his/her password due to any policy settings
if PasswordHistory.should_user_reset_password_now(user_found_by_email_lookup): if user_found_by_email_lookup and PasswordHistory.should_user_reset_password_now(user_found_by_email_lookup):
return JsonResponse({ return JsonResponse({
"success": False, "success": False,
"value": _('Your password has expired due to password policy on this account. You must ' "value": _('Your password has expired due to password policy on this account. You must '
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment