This commit is contained in:
Paul Konstantin Gerke 2023-06-25 23:31:22 +02:00 committed by Christopher Charbonneau Wells
parent a37258db1a
commit 643c9bec13
2 changed files with 5 additions and 12 deletions

View File

@ -9,6 +9,7 @@ from django.utils import timezone, translation
from django.contrib.auth.middleware import RemoteUserMiddleware
from django.http import HttpRequest
class UserLanguageMiddleware:
"""
Customizes settings based on user language setting.
@ -113,6 +114,7 @@ class HomeAssistant:
)
return url
return wrapper
request.is_homeassistant_ingress_request = (
@ -120,10 +122,6 @@ class HomeAssistant:
)
if self.use_x_ingress_path_rewrite:
request.build_absolute_uri = wrap_x_ingress_path(
request.build_absolute_uri
)
request.build_absolute_uri = wrap_x_ingress_path(request.build_absolute_uri)
return self.get_response(request)

View File

@ -255,17 +255,12 @@ class UserAddDevice(LoginRequiredMixin, View):
def get(self, request):
session_cookies = {}
if request.is_homeassistant_ingress_request:
session_cookies["ingress_session"] = (
request.COOKIES.get("ingress_session")
)
session_cookies["ingress_session"] = request.COOKIES.get("ingress_session")
qr_code_response = render(
request,
self.qr_code_template,
{
"session_cookies": json.dumps(session_cookies)
}
{"session_cookies": json.dumps(session_cookies)},
)
qr_code_data = qr_code_response.content.decode().strip()