소스 검색

More elegant path checking

Lars Weiler 6 년 전
부모
커밋
560c8d6f01
1개의 변경된 파일1개의 추가작업 그리고 3개의 파일을 삭제
  1. 1 3
      netbox/utilities/middleware.py

+ 1 - 3
netbox/utilities/middleware.py

@@ -21,9 +21,7 @@ class LoginRequiredMiddleware(object):
             # Redirect unauthenticated requests to the login page. API requests are exempt from redirection as the API
             # performs its own authentication. Also metrics can be read without login.
             api_path = reverse('api-root')
-            if (not (request.path_info.startswith(api_path) or
-                     request.path_info.startswith('/metrics')) and
-                    request.path_info != settings.LOGIN_URL):
+            if not request.path_info.startswith(api_path, '/metrics') and request.path_info != settings.LOGIN_URL:
                 return HttpResponseRedirect('{}?next={}'.format(settings.LOGIN_URL, request.path_info))
         return self.get_response(request)