fix: guard against duplicate callback — skip token exchange if already stored
All checks were successful
Build and Deploy / deploy (push) Successful in 37s

This commit is contained in:
Henrik Jess Nielsen
2026-05-23 01:06:45 +02:00
parent ba38cb1e47
commit c3bc6a48a0

View File

@@ -402,6 +402,11 @@ async def tink_callback(request: Request, code: Optional[str] = None,
print(f"[CALLBACK] Tink returned error: {error}")
return RedirectResponse(f"/demo/step/3?error={error}")
if code:
# Guard: if we already have a user_token for this session, the code was
# already exchanged (duplicate callback from Traefik during rolling deploy).
if _load_token(sess, "user_token"):
print(f"[CALLBACK] Already have user_token — skipping duplicate exchange")
return RedirectResponse("/demo/step/3?cb_success=1", status_code=303)
try:
s = get_settings()
print(f"[CALLBACK] Exchanging code, redirect_uri={s.tink_redirect_uri!r}")