parent
533c7767e8
commit
d41d53367f
|
@ -20,10 +20,14 @@ def verify_auth_token(token: str) -> str | None:
|
||||||
|
|
||||||
|
|
||||||
def require_authentication() -> werkzeug.Response | None:
|
def require_authentication() -> werkzeug.Response | None:
|
||||||
"""Require authentication."""
|
"""Require authentication and redirect with return URL."""
|
||||||
token = flask.request.cookies.get("auth_token")
|
token = flask.request.cookies.get("auth_token")
|
||||||
return (
|
if token and verify_auth_token(token):
|
||||||
None
|
return None
|
||||||
if token and verify_auth_token(token)
|
|
||||||
else flask.redirect(flask.current_app.config["UNIAUTH_LOGIN_URL"])
|
# Construct the redirect URL with the original URL as a parameter
|
||||||
|
return flask.redirect(
|
||||||
|
flask.current_app.config["UNIAUTH_LOGIN_URL"]
|
||||||
|
+ "?next="
|
||||||
|
+ werkzeug.urls.url_quote(flask.request.url)
|
||||||
)
|
)
|
||||||
|
|
Loading…
Reference in a new issue