diff --git a/backend/videoflix/auth/views.py b/backend/videoflix/auth/views.py index cc533d2..c112b1b 100644 --- a/backend/videoflix/auth/views.py +++ b/backend/videoflix/auth/views.py @@ -144,4 +144,10 @@ class AuthView(ObtainAuthToken): def get(self, request): if request.user.is_authenticated: return Response(request.user.id, status=status.HTTP_200_OK) - return Response({"error": "User is not logged in"}, status=status.HTTP_401_UNAUTHORIZED) \ No newline at end of file + return Response({"error": "User is not logged in"}, status=status.HTTP_401_UNAUTHORIZED) + + def post(self, request): + email = request.data.get('email') + if CustomUser.objects.filter(email=email).exists(): + return Response({'mail': 'A user with this email already exists.'}, status=status.HTTP_400_BAD_REQUEST) + return Response(status=status.HTTP_200_OK) \ No newline at end of file diff --git a/frontend/src/app/components/auth/auth.component.html b/frontend/src/app/components/auth/auth.component.html index 82c7710..5a77ea9 100644 --- a/frontend/src/app/components/auth/auth.component.html +++ b/frontend/src/app/components/auth/auth.component.html @@ -33,6 +33,11 @@ !isUserEmailValid(authData.mail.toLowerCase())) {
This is not a valid email format
}} +{{ errors["mail"] }}
+