mirror of
https://github.com/Tivix/django-rest-auth.git
synced 2024-11-25 10:33:45 +03:00
Merge pull request #145 from mdentremont/topic/131
#131: Do not raise 400 when resetting password for non-existing account
This commit is contained in:
commit
00415301d6
|
@ -151,9 +151,6 @@ class PasswordResetSerializer(serializers.Serializer):
|
||||||
if not self.reset_form.is_valid():
|
if not self.reset_form.is_valid():
|
||||||
raise serializers.ValidationError(_('Error'))
|
raise serializers.ValidationError(_('Error'))
|
||||||
|
|
||||||
if not UserModel.objects.filter(email__iexact=value).exists():
|
|
||||||
raise serializers.ValidationError(_('Invalid e-mail address'))
|
|
||||||
|
|
||||||
return value
|
return value
|
||||||
|
|
||||||
def save(self):
|
def save(self):
|
||||||
|
|
|
@ -280,12 +280,15 @@ class APITestCase1(TestCase, BaseAPITestCase):
|
||||||
self.assertEqual(len(mail.outbox), mail_count + 1)
|
self.assertEqual(len(mail.outbox), mail_count + 1)
|
||||||
|
|
||||||
def test_password_reset_with_invalid_email(self):
|
def test_password_reset_with_invalid_email(self):
|
||||||
|
"""
|
||||||
|
Invalid email should not raise error, as this would leak users
|
||||||
|
"""
|
||||||
get_user_model().objects.create_user(self.USERNAME, self.EMAIL, self.PASS)
|
get_user_model().objects.create_user(self.USERNAME, self.EMAIL, self.PASS)
|
||||||
|
|
||||||
# call password reset
|
# call password reset
|
||||||
mail_count = len(mail.outbox)
|
mail_count = len(mail.outbox)
|
||||||
payload = {'email': 'nonexisting@email.com'}
|
payload = {'email': 'nonexisting@email.com'}
|
||||||
self.post(self.password_reset_url, data=payload, status_code=400)
|
self.post(self.password_reset_url, data=payload, status_code=200)
|
||||||
self.assertEqual(len(mail.outbox), mail_count)
|
self.assertEqual(len(mail.outbox), mail_count)
|
||||||
|
|
||||||
def test_user_details(self):
|
def test_user_details(self):
|
||||||
|
|
Loading…
Reference in New Issue
Block a user