api: respect ?next= url parmeter on login

This commit is contained in:
lilly 2026-05-14 16:33:06 +02:00
commit 5e7569395b
Signed by: lilly
SSH key fingerprint: SHA256:y9T5GFw2A20WVklhetIxG1+kcg/Ce0shnQmbu1LQ37g

View file

@ -147,16 +147,19 @@ async def login_callback(req: Request, resp: Response, oidc_client: deps.OpenidC
deps.persist_auth_state(
oidc_client, resp, auth_result, auth_start_time, req.cookies["auth_nonce"]
)
# redirect the user to the page they wanted to visit
# TODO: respect "auth_next" cookie to redirect the user to a specific url
logger.debug("successfully authenticated user")
return str(req.url_for("get-user-info"))
# respect originally requested ?next= url and reset the storage
resp.set_cookie("auth_next", "", max_age=0)
if "auth_next" in req.cookies:
return req.cookies["auth_next"]
else:
return "/"
else:
logger.debug(
"could not authenticate user because of OIDC error; redirecting to error page with error messages intact"
)
return f"/auth/login-error?{req.query_params}"
return f"/login-error?{req.query_params}"
@app.get(