1
0
Fork 0
mirror of https://github.com/seanmorley15/AdventureLog.git synced 2025-07-25 07:49:37 +02:00

Merge pull request #216 from seanmorley15/development

Fix password reset issue
This commit is contained in:
Sean Morley 2024-08-16 11:48:14 -04:00 committed by GitHub
commit 3fb4a67e3c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -23,6 +23,9 @@ class ChangeEmailView(APIView):
user = request.user
new_email = serializer.validated_data['new_email']
user.email = new_email
# remove all other email addresses for the user
user.emailaddress_set.exclude(email=new_email).delete()
user.emailaddress_set.create(email=new_email, primary=True, verified=False)
user.save()
return Response({"detail": "Email successfully changed."}, status=status.HTTP_200_OK)
return Response(serializer.errors, status=status.HTTP_400_BAD_REQUEST)