diff --git a/breathecode/authenticate/tests/urls/v1/tests_email_verification.py b/breathecode/authenticate/tests/urls/v1/tests_email_verification.py index 583ff2e89..5ebf09410 100644 --- a/breathecode/authenticate/tests/urls/v1/tests_email_verification.py +++ b/breathecode/authenticate/tests/urls/v1/tests_email_verification.py @@ -4,9 +4,9 @@ import pytest from django.urls.base import reverse_lazy +from linked_services.django.actions import reset_app_cache from rest_framework import status from rest_framework.test import APIClient -from linked_services.django.actions import reset_app_cache from breathecode.tests.mixins.breathecode_mixin.breathecode import Breathecode @@ -24,10 +24,10 @@ def test_email_verification_no_user(bc: Breathecode, client: APIClient): response = client.get(url) json = response.json() - expected = {"detail": "email-not-found", "status_code": 400} + expected = {"detail": "email-not-found", "status_code": 404} assert json == expected - assert response.status_code == status.HTTP_400_BAD_REQUEST + assert response.status_code == status.HTTP_404_NOT_FOUND def test_email_verification_not_validated(bc: Breathecode, client: APIClient): @@ -39,10 +39,10 @@ def test_email_verification_not_validated(bc: Breathecode, client: APIClient): response = client.get(url) json = response.json() - expected = {"detail": "email-not-validated", "status_code": 400} + expected = {"detail": "email-not-validated", "status_code": 403} assert json == expected - assert response.status_code == status.HTTP_400_BAD_REQUEST + assert response.status_code == status.HTTP_403_FORBIDDEN def test_email_verification(bc: Breathecode, client: APIClient): diff --git a/breathecode/authenticate/views.py b/breathecode/authenticate/views.py index ceadbcd10..70d347c47 100644 --- a/breathecode/authenticate/views.py +++ b/breathecode/authenticate/views.py @@ -534,26 +534,30 @@ class EmailVerification(APIView): permission_classes = [AllowAny] def get(self, request, email=None): - get_user_language(request) + lang = get_user_language(request) invite = UserInvite.objects.filter(email=email).first() user = User.objects.filter(email=email).first() if user is None and invite is None: raise ValidationException( translation( + lang, en="We could not find an account with this email", es="No pudimos encontrar una dirección con este email", ), slug="email-not-found", + code=404, ) if invite is not None and not invite.is_email_validated: raise ValidationException( translation( + lang, en="You need to validate your email first", es="Debes validar tu email primero", ), slug="email-not-validated", + code=403, ) return Response(None, status=status.HTTP_204_NO_CONTENT)