Add Home Assistant shopping API
This commit is contained in:
+6
-2
@@ -73,6 +73,10 @@ def url_with_scroll_position(url: str) -> str:
|
||||
return urlunsplit((parts.scheme, parts.netloc, parts.path, urlencode(query), parts.fragment))
|
||||
|
||||
|
||||
def is_home_assistant_api_endpoint(endpoint: str) -> bool:
|
||||
return endpoint.startswith("main.home_assistant_")
|
||||
|
||||
|
||||
def normalize_login_value(raw: str) -> str:
|
||||
return raw.strip().lower()
|
||||
|
||||
@@ -136,10 +140,10 @@ def load_logged_in_user():
|
||||
g.user = None
|
||||
|
||||
endpoint = request.endpoint or ""
|
||||
if user_count() == 0 and endpoint not in {"auth.setup", "static", "uploaded_file"}:
|
||||
if user_count() == 0 and endpoint not in {"auth.setup", "static", "uploaded_file"} and not is_home_assistant_api_endpoint(endpoint):
|
||||
return redirect(url_for("auth.setup"))
|
||||
|
||||
if request.method == "POST" and endpoint != "static":
|
||||
if request.method == "POST" and endpoint != "static" and not is_home_assistant_api_endpoint(endpoint):
|
||||
token = session.get("_csrf_token")
|
||||
form_token = request.form.get("csrf_token")
|
||||
if not token or token != form_token:
|
||||
|
||||
Reference in New Issue
Block a user