Commit cedfb93
fix(account): resume oauth2 flow after login/register on cloud IdP
When better-auth's oauth-provider redirects an unauthenticated user from
/oauth2/authorize to loginPage (/_account/login), it preserves the full
authorize query — client_id, redirect_uri, signed sig, state, etc. — on the
target URL. After the user authenticates we must replay those same params
back to /oauth2/authorize so the IdP can issue the code and 302 the user
home to the RP (e.g. crm.objectos.app).
Without this hand-off, the login page falls through to its default landing
(window.location.assign('/')) and the user ends up on the cloud Studio
dashboard while the RP never sees the callback — the SSO flow stalls
silently from the user's perspective.
Detect the flow via the presence of `client_id` + `redirect_uri` query
params (the signed `sig` would also work but these are mandatory per the
authorize spec). Apply the same fix to /register so a user who chooses to
sign up mid-SSO also lands back on the RP rather than the IdP dashboard.
Consent step is already bypassed for first-party platform SSO clients
(seedPlatformSsoClient sets skip_consent=true), so the resumed authorize
call returns the code immediately.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>1 parent 6bae429 commit cedfb93
2 files changed
Lines changed: 30 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
61 | 61 | | |
62 | 62 | | |
63 | 63 | | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
64 | 82 | | |
65 | 83 | | |
66 | 84 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
54 | 54 | | |
55 | 55 | | |
56 | 56 | | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
57 | 69 | | |
58 | 70 | | |
59 | 71 | | |
| |||
0 commit comments