feat: implement user authentication, profile management, and WhatsApp OTP verification views
All checks were successful
Deploy Beta (NATIVE) / deploy (push) Successful in 24s

This commit is contained in:
vickytechkey 2026-10-04 11:37:09 +05:30
parent e479c210e2
commit 3ac7e6eb8f

View file

@ -128,22 +128,26 @@ class SendWhatsAppOTPView(APIView):
raw_10 = clean_phone[-10:] if len(clean_phone) >= 10 else clean_phone
# Account existence validation
user_exists = False
from django.db.models import Q
user_exists = None
try:
from orders.models import CustomerProfile
user_exists = User.objects.filter(username__icontains=raw_10).exists() or CustomerProfile.objects.filter(phone__icontains=raw_10).exists()
user_exists = (
User.objects.filter(Q(username__icontains=raw_10) | Q(email__icontains=raw_10)).exists()
or CustomerProfile.objects.filter(Q(phone__icontains=raw_10) | Q(user__username__icontains=raw_10)).exists()
)
except Exception as db_err:
audit_logger.warning(f"DB lookup notice for {mobile_number}: {db_err}")
user_exists = False
user_exists = None
if purpose == 'login' and not user_exists:
if purpose == 'login' and user_exists is False:
audit_logger.warning(f"AUDIT - Login attempt for non-existent mobile: '{mobile_number}'")
return Response({
"status": "error",
"message": "Account not found. Please create a patron account first."
}, status=status.HTTP_404_NOT_FOUND)
if purpose == 'register' and user_exists:
if purpose == 'register' and user_exists is True:
audit_logger.warning(f"AUDIT - Register attempt for existing mobile: '{mobile_number}'")
return Response({
"status": "error",