diff --git a/agenda/auth.py b/agenda/auth.py index 925ead3..fefbee9 100644 --- a/agenda/auth.py +++ b/agenda/auth.py @@ -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) ) diff --git a/web_view.py b/web_view.py index 259e751..91e9cc2 100755 --- a/web_view.py +++ b/web_view.py @@ -70,12 +70,12 @@ async def index() -> str: @app.route("/launches") -async def launch_list() -> str: +def launch_list() -> str: """Web page showing List of space launches.""" now = datetime.now() data_dir = app.config["DATA_DIR"] rocket_dir = os.path.join(data_dir, "thespacedevs") - rockets = await agenda.thespacedevs.get_launches(rocket_dir, limit=100) + rockets = agenda.thespacedevs.get_launches(rocket_dir, limit=100) return flask.render_template( "launches.html", rockets=rockets, now=now, get_country=agenda.get_country