mirror of
https://github.com/HamzaSha1/zod-backend.git
synced 2025-07-14 17:45:46 +00:00
login api with user type
This commit is contained in:
@ -295,18 +295,28 @@ class UserLogin(viewsets.ViewSet):
|
||||
try:
|
||||
if user is not None:
|
||||
login(request, user)
|
||||
if user_type == USER_TYPE_FLAG["FIRST"]:
|
||||
if user_type == USER_TYPE_FLAG["TWO"]:
|
||||
guardian_data = Guardian.objects.filter(user__username=username, is_verified=True).last()
|
||||
if guardian_data:
|
||||
serializer = GuardianSerializer(
|
||||
guardian_data, context={'user_type': user_type}
|
||||
).data
|
||||
elif user_type == USER_TYPE_FLAG["TWO"]:
|
||||
else:
|
||||
return custom_error_response(
|
||||
ERROR_CODE["2070"],
|
||||
response_status=status.HTTP_401_UNAUTHORIZED
|
||||
)
|
||||
elif user_type == USER_TYPE_FLAG["FIRST"]:
|
||||
junior_data = Junior.objects.filter(auth__username=username, is_verified=True).last()
|
||||
if junior_data:
|
||||
serializer = JuniorSerializer(
|
||||
junior_data, context={'user_type': user_type}
|
||||
).data
|
||||
else:
|
||||
return custom_error_response(
|
||||
ERROR_CODE["2071"],
|
||||
response_status=status.HTTP_401_UNAUTHORIZED
|
||||
)
|
||||
else:
|
||||
return custom_error_response(
|
||||
ERROR_CODE["2069"],
|
||||
|
@ -95,7 +95,9 @@ ERROR_CODE = {
|
||||
"2066": "Task does not exist or not in expired state",
|
||||
"2067": "Action not allowed. User type missing.",
|
||||
"2068": "No guardian associated with this junior",
|
||||
"2069": "Invalid user type"
|
||||
"2069": "Invalid user type",
|
||||
"2070": "You did not find as a guardian",
|
||||
"2071": "You did not find as a junior"
|
||||
|
||||
}
|
||||
"""Success message code"""
|
||||
|
Reference in New Issue
Block a user