|
|
|
@ -37,19 +37,13 @@ def authenticate_customer(request):
|
|
|
|
|
|
|
|
|
|
try:
|
|
|
|
|
user = User.objects.get(email=email)
|
|
|
|
|
except User.DoesNotExist:
|
|
|
|
|
return JsonResponse({'success': False, 'error': 'User with this email does not exist'})
|
|
|
|
|
|
|
|
|
|
# Since you're not checking the password, you can simply authenticate the user object
|
|
|
|
|
user = authenticate(request, user=user)
|
|
|
|
|
|
|
|
|
|
if user is not None:
|
|
|
|
|
# Login the user
|
|
|
|
|
login(request, user)
|
|
|
|
|
return JsonResponse({'success': True, 'user': {
|
|
|
|
|
'id': user.id,
|
|
|
|
|
'email': user.email,
|
|
|
|
|
'username': user.username
|
|
|
|
|
}})
|
|
|
|
|
else:
|
|
|
|
|
return JsonResponse({'success': False, 'error': 'Authentication failed'})
|
|
|
|
|
except User.DoesNotExist:
|
|
|
|
|
return JsonResponse({'success': False, 'error': 'User with this email does not exist'})
|
|
|
|
|
|
|
|
|
|