From ac32b4fe895b6fac9613d1af0e08943d71985f36 Mon Sep 17 00:00:00 2001 From: Edward Betts Date: Sun, 21 Jan 2024 15:56:18 +0000 Subject: [PATCH 1/2] Bug fix --- web_view.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/web_view.py b/web_view.py index 99e5cf7..6141035 100755 --- a/web_view.py +++ b/web_view.py @@ -67,12 +67,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 From d41d53367fdb6462e3625f8a375a501fdc26ab3c Mon Sep 17 00:00:00 2001 From: Edward Betts Date: Sun, 21 Jan 2024 16:23:46 +0000 Subject: [PATCH 2/2] Redirect back to agenda after login Closes: #91 --- agenda/auth.py | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/agenda/auth.py b/agenda/auth.py index d44696a..3e2f2b8 100644 --- a/agenda/auth.py +++ b/agenda/auth.py @@ -20,10 +20,14 @@ def verify_auth_token(token: str) -> str | None: def require_authentication() -> werkzeug.Response | None: - """Require authentication.""" + """Require authentication and redirect with return URL.""" token = flask.request.cookies.get("auth_token") - return ( - None - if token and verify_auth_token(token) - else flask.redirect(flask.current_app.config["UNIAUTH_LOGIN_URL"]) + 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=" + + werkzeug.urls.url_quote(flask.request.url) )