unrestrict logout and refresh token api while login in multiple device

This commit is contained in:
jain
2023-09-01 16:25:05 +05:30
parent 0af2a35206
commit 4f79a690c1
5 changed files with 31 additions and 47 deletions

View File

@ -45,11 +45,12 @@ class CustomMiddleware(object):
device_type = str(request.META.get('HTTP_TYPE'))
api_endpoint = request.path
unrestricted_api = ('/api/v1/user/login/', '/api/v1/logout/', '/api/v1/generate-token/')
if request.user.is_authenticated:
# device details
if device_id:
device_details = UserDeviceDetails.objects.filter(user=request.user, device_id=device_id).last()
if not device_details and api_endpoint != '/api/v1/user/login/':
if not device_details and api_endpoint not in unrestricted_api:
custom_error = custom_error_response(ERROR_CODE['2037'], response_status=status.HTTP_404_NOT_FOUND)
response = custom_response(custom_error)
if user_type and str(user_type) == str(NUMBER['one']):