fix: handle missing transaction cookie with auth-state-aware response#797
fix: handle missing transaction cookie with auth-state-aware response#797cschetan77 merged 7 commits intomasterfrom
Conversation
|
Hey @aks96, went through the issue and fix being implemented in this PR -
Let me know your thoughts. |
|
Thank you for your review.
I've revised this PR to make cookie path configuration opt-in rather than auto-derived. No breaking change |
…me for deploying multiple apps on same domain
|
Thank you @cschetan77 ! |
Description
Problem
When the
auth_verificationtransaction cookie is absent at the callback route, the SDK threw:BadRequestError: checks.state argument is missingThis message is an internal
openid-clientdetail, it gives developers no indication of why the cookie is missing or how to fix it. The same opaque error surfaced across three distinct root causes:transactionCookie.nameandcookie.path, one app's login overwrote the other's cookieFix
After
getOnce()returns undefined, the handler now branches on authentication state:Authenticated user → silent redirect to baseURL
The transaction cookie was legitimately consumed on the first successful callback. The browser re-firing the same URL is a benign back-button navigation. The user is already logged in — redirect them home with no error.
Unauthenticated user → descriptive 400 error
The cookie is missing for a user who hasn't established a session yet. The error message names the cookie, lists all four root causes, and suggests fix for each — replacing the cryptic
checks.state argument is missingwith actionable developer guidance.Testing