From 8de37ca46560496a79b4042f3fc025fd28107574 Mon Sep 17 00:00:00 2001 From: Mariano Baragiola Date: Tue, 31 Oct 2017 13:24:37 -0300 Subject: [PATCH] Resend confirmation email When trying to login using an unverified email address, resend confirmation email. --- rest_auth/serializers.py | 3 +++ rest_auth/tests/test_api.py | 1 + 2 files changed, 4 insertions(+) diff --git a/rest_auth/serializers.py b/rest_auth/serializers.py index c5dad7d..bae8859 100644 --- a/rest_auth/serializers.py +++ b/rest_auth/serializers.py @@ -104,6 +104,9 @@ class LoginSerializer(serializers.Serializer): if app_settings.EMAIL_VERIFICATION == app_settings.EmailVerificationMethod.MANDATORY: email_address = user.emailaddress_set.get(email=user.email) if not email_address.verified: + email_address.send_confirmation( + request=self.context.get('request') + ) raise serializers.ValidationError(_('E-mail is not verified.')) attrs['user'] = user diff --git a/rest_auth/tests/test_api.py b/rest_auth/tests/test_api.py index d33635c..80b4bdd 100644 --- a/rest_auth/tests/test_api.py +++ b/rest_auth/tests/test_api.py @@ -482,6 +482,7 @@ class APIBasicTests(TestsMixin, TestCase): data={"key": email_confirmation.key}, status_code=status.HTTP_200_OK ) + self.assertEqual(len(mail.outbox), mail_count + 1) # try to login again self._login()