Compare commits

..

3 commits

View file

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