middleware

This commit is contained in:
jain
2023-08-18 18:12:14 +05:30
parent 5b236dfc81
commit b4026a4f11
5 changed files with 19 additions and 7 deletions

View File

@ -39,8 +39,9 @@ class CustomMiddleware(object):
# Code to be executed after the view is called
device_id = request.META.get('HTTP_DEVICE_ID')
user_type = request.META.get('HTTP_USER_TYPE')
api_endpoint = request.path
if request.user.is_authenticated:
"""device details"""
# device details
device_details = UserDeviceDetails.objects.filter(user=request.user, device_id=device_id).last()
if user_type and str(user_type) == str(NUMBER['one']):
junior = Junior.objects.filter(auth=request.user, is_active=False).last()
@ -52,7 +53,7 @@ class CustomMiddleware(object):
if guardian:
custom_error = custom_error_response(ERROR_CODE['2075'], response_status=status.HTTP_404_NOT_FOUND)
response = custom_response(custom_error)
if device_id and not device_details:
if device_id and not device_details and api_endpoint != '/api/v1/user/login/':
custom_error = custom_error_response(ERROR_CODE['2037'], response_status=status.HTTP_404_NOT_FOUND)
response = custom_response(custom_error)
return response