mirror of
https://github.com/i701/sarlink-portal-api.git
synced 2025-04-19 23:46:53 +00:00
Refactor VerifyOTPView to check for existing TemporaryUser and return appropriate error messages
All checks were successful
Build and Push Docker Images / Build and Push Docker Images (push) Successful in 3m15s
All checks were successful
Build and Push Docker Images / Build and Push Docker Images (push) Successful in 3m15s
This commit is contained in:
parent
900a87466f
commit
ac5675e923
@ -18,6 +18,7 @@ from api.serializers import (
|
|||||||
OTPVerificationSerializer,
|
OTPVerificationSerializer,
|
||||||
TemporaryUserSerializer,
|
TemporaryUserSerializer,
|
||||||
)
|
)
|
||||||
|
from django.shortcuts import get_object_or_404
|
||||||
|
|
||||||
# knox imports
|
# knox imports
|
||||||
from knox.views import LoginView as KnoxLoginView
|
from knox.views import LoginView as KnoxLoginView
|
||||||
@ -207,11 +208,11 @@ class VerifyOTPView(generics.GenericAPIView):
|
|||||||
serializer.is_valid(raise_exception=True)
|
serializer.is_valid(raise_exception=True)
|
||||||
data = request.data
|
data = request.data
|
||||||
mobile = data.get("mobile")
|
mobile = data.get("mobile")
|
||||||
|
t_user = get_object_or_404(TemporaryUser, t_mobile=mobile)
|
||||||
|
if not t_user:
|
||||||
|
return Response({"message": "User not found."}, status=404)
|
||||||
|
|
||||||
if (
|
if User.objects.filter(username=t_user.t_username).exists():
|
||||||
User.objects.filter(mobile=mobile).exists()
|
|
||||||
or TemporaryUser.objects.filter(t_mobile=mobile).exists()
|
|
||||||
):
|
|
||||||
return Response(
|
return Response(
|
||||||
{"message": "User with this mobile number already registered."},
|
{"message": "User with this mobile number already registered."},
|
||||||
status=400,
|
status=400,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user