username integrity error solved
This commit is contained in:
@@ -666,7 +666,18 @@ class GoogleLoginAPIView(APIView):
|
||||
)
|
||||
|
||||
principal_info = self.get_google_user_data(access_token)
|
||||
("principal_info: ", principal_info)
|
||||
print("principal_info: ", principal_info)
|
||||
|
||||
# Check if there was an error in fetching user data
|
||||
if "error" in principal_info:
|
||||
error_message = principal_info.get("error", {}).get(
|
||||
"error_description", "An error occurred while fetching user data."
|
||||
)
|
||||
return Response(
|
||||
{"error": error_message},
|
||||
status=principal_info.get("status", status.HTTP_400_BAD_REQUEST),
|
||||
)
|
||||
|
||||
if not principal_info:
|
||||
return Response(
|
||||
{"error": "Failed to fetch user details or invalid access token"},
|
||||
@@ -679,7 +690,7 @@ class GoogleLoginAPIView(APIView):
|
||||
{"error": "Email is required but not provided."},
|
||||
status=status.HTTP_400_BAD_REQUEST,
|
||||
)
|
||||
("email: ", email)
|
||||
print("email: ", email)
|
||||
serializer = EmailSerializer(
|
||||
data={"email": email, "principal_type": principal_type}
|
||||
)
|
||||
@@ -698,6 +709,7 @@ class GoogleLoginAPIView(APIView):
|
||||
|
||||
principal, created = IAmPrincipal.objects.update_or_create(
|
||||
email=email,
|
||||
username=email,
|
||||
defaults=defaults,
|
||||
)
|
||||
principal_type_instance = IAmPrincipalType.objects.get(name=principal_type)
|
||||
|
||||
Reference in New Issue
Block a user