diff --git a/authentik/brands/middleware.py b/authentik/brands/middleware.py index 52af854e332f..dd72038ab8cf 100644 --- a/authentik/brands/middleware.py +++ b/authentik/brands/middleware.py @@ -25,5 +25,7 @@ def __call__(self, request: HttpRequest) -> HttpResponse: locale = brand.default_locale if locale != "": locale_to_set = locale - with override(locale_to_set): - return self.get_response(request) + if locale_to_set: + with override(locale_to_set): + return self.get_response(request) + return self.get_response(request) diff --git a/authentik/core/middleware.py b/authentik/core/middleware.py index 1d20455a1ba9..811b1eceb2a1 100644 --- a/authentik/core/middleware.py +++ b/authentik/core/middleware.py @@ -42,8 +42,10 @@ def __call__(self, request: HttpRequest) -> HttpResponse: # Ensure that the user is active, otherwise nothing will work request.user.is_active = True - with override(locale_to_set): - return self.get_response(request) + if locale_to_set: + with override(locale_to_set): + return self.get_response(request) + return self.get_response(request) class RequestIDMiddleware: