iMerica / dj-rest-auth

Authentication for Django Rest Framework
https://dj-rest-auth.readthedocs.io/en/latest/index.html
MIT License
1.63k stars 304 forks source link

Incorrect Response in ResendEmailVerificationView #511

Open uzza1hossain opened 1 year ago

uzza1hossain commented 1 year ago

When email is not found or already verified, shouldn't we return HTTP_404_NOT_FOUND? Current version: https://github.com/iMerica/dj-rest-auth/blob/master/dj_rest_auth/registration/views.py#LL122-L130

Proposed version:

def create(self, request, *args, **kwargs):
        serializer = self.get_serializer(data=request.data)
        serializer.is_valid(raise_exception=True)

        email = EmailAddress.objects.filter(**serializer.validated_data).first()
        if email and not email.verified:
            email.send_confirmation(request)
            return Response({'detail': _('ok')}, status=status.HTTP_200_OK)
        return Response({'detail': _('Not found.')}, status=status.HTTP_404_NOT_FOUND)