Merge branch 'main' of https://git.4angle.com/edward/agenda
This commit is contained in:
commit
cc3dc81bdb
2 changed files with 11 additions and 7 deletions
|
|
@ -20,13 +20,17 @@ def verify_auth_token(token: str) -> str | None:
|
|||
|
||||
|
||||
def require_authentication() -> werkzeug.Response | None:
|
||||
"""Require authentication."""
|
||||
"""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")
|
||||
return (
|
||||
None
|
||||
if token and verify_auth_token(token)
|
||||
else flask.redirect(flask.current_app.config["UNIAUTH_URL"] + "/login")
|
||||
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_URL"]
|
||||
+ "/login?next="
|
||||
+ werkzeug.urls.url_quote(flask.request.url)
|
||||
)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue