Compare commits

..

3 commits

View file

@ -21,13 +21,16 @@ def verify_auth_token(token: str) -> str | None:
def require_authentication() -> werkzeug.Response | None:
"""Require authentication and redirect with return URL."""
if not flask.current_app.config.get("REQUIRE_AUTH"):
return None
token = flask.request.cookies.get("auth_token")
if token and verify_auth_token(token):
return None
# Construct the redirect URL with the original URL as a parameter
return flask.redirect(
flask.current_app.config["UNIAUTH_LOGIN_URL"]
+ "?next="
flask.current_app.config["UNIAUTH_URL"]
+ "/login?next="
+ werkzeug.urls.url_quote(flask.request.url)
)