Skip to content

Commit

Permalink
root: fix override locale only if it is not empty (goauthentik#12283)
Browse files Browse the repository at this point in the history
* update impersonate middleware

override language only if it's not empty

Signed-off-by: Zhang Jie <[email protected]>

* Update brands locale scope

Signed-off-by: Zhang Jie <[email protected]>

---------

Signed-off-by: Zhang Jie <[email protected]>
  • Loading branch information
j-z10 authored Dec 6, 2024
1 parent eef1237 commit 98c4344
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
6 changes: 4 additions & 2 deletions authentik/brands/middleware.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
6 changes: 4 additions & 2 deletions authentik/core/middleware.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit 98c4344

Please sign in to comment.