From 86d17576fbcc86a73f7a3121f7e93b99e35d448d Mon Sep 17 00:00:00 2001 From: Renan Lopes Date: Fri, 24 May 2024 17:48:21 -0300 Subject: [PATCH] bugfix --- networkapi/middlewares.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/networkapi/middlewares.py b/networkapi/middlewares.py index 4f5f1aef9..3339a4fea 100644 --- a/networkapi/middlewares.py +++ b/networkapi/middlewares.py @@ -65,12 +65,18 @@ def process_request(self, request): AuditRequest.new_request(request.get_full_path(), request.user, ip, identity, context) else: - user_auth_tuple = BasicAuthentication().authenticate(request) + try: + user_auth_tuple = BasicAuthentication().authenticate(request) + except Exception as ex: + user_auth_tuple = None if user_auth_tuple is not None: user, token = user_auth_tuple else: # keeps compatibility with old authentication method - user = RestResource.authenticate_user(request) + try: + user = RestResource.authenticate_user(request) + except Exception as ex: + user = None if user is not None: ip = self._get_ip(request)