Merge pull request #26413 from edx/reset-password-success-email

reset-password-success-email
This commit is contained in:
Uzair Rasheed
2021-02-06 17:01:01 +05:00
committed by GitHub
2 changed files with 4 additions and 3 deletions

View File

@@ -715,10 +715,10 @@ class LogistrationPasswordResetView(APIView): # lint-amnesty, pylint: disable=m
}
)
user.save()
send_password_reset_success_email(user, request)
except ObjectDoesNotExist:
err = 'Account recovery process initiated without AccountRecovery instance for user {username}'
log.error(err.format(username=user.username))
send_password_reset_success_email(user, request)
except ValidationError as err:
AUDIT_LOG.exception("Password validation failed")
error_status = {

View File

@@ -824,12 +824,13 @@ class ResetPasswordAPITests(EventTestMixin, CacheIsolationTestCase):
new=updated_user.email
)
def test_password_reset_email_sent_on_account_recovery_email(self):
@ddt.data(True, False)
def test_password_reset_email_successfully_sent(self, is_account_recovery):
"""
Test that with is_account_recovery query param available, password
reset email is sent to newly updated email address.
"""
post_request = self.create_reset_request(self.uidb36, self.token, True)
post_request = self.create_reset_request(self.uidb36, self.token, is_account_recovery)
post_request.user = AnonymousUser()
post_request.site = Mock(domain='example.com')
reset_view = LogistrationPasswordResetView.as_view()