From 9de95a74087f10d4505878ff799ca13eaf38fd59 Mon Sep 17 00:00:00 2001 From: vickytechkey Date: Sun, 4 Oct 2026 11:43:26 +0530 Subject: [PATCH] feat: add user registration, profile management, and WhatsApp OTP authentication views --- api/views.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/api/views.py b/api/views.py index 0393399..8a97c80 100644 --- a/api/views.py +++ b/api/views.py @@ -21,6 +21,13 @@ class UserRegisterView(APIView): serializer.save() audit_logger.info(f"AUDIT - User Register: Username '{serializer.validated_data.get('username')}' registered successfully.") return Response({"message": "User registered successfully"}, status=status.HTTP_201_CREATED) + else: + username = request.data.get('username') + phone = request.data.get('phone', username) + if username and User.objects.filter(username=username).exists(): + user = User.objects.get(username=username) + CustomerProfile.objects.get_or_create(user=user, defaults={'phone': phone or username}) + return Response({"message": "User account already registered"}, status=status.HTTP_200_OK) return Response(serializer.errors, status=status.HTTP_400_BAD_REQUEST) class UserProfileView(APIView):