Commit 469060f
fix(web): reject OAuth account-linking when no signed-in session
If a user clicks "Connect Bitbucket" and their session-token cookie is
missing or expired by the time the BB redirect arrives at our callback,
@auth/core silently falls through to createUser and mints a new orphan
User row from the OAuth profile. The orphan has no email, no UserToOrg,
and the user's session cookie gets rebound to it, leaving them on a
"request access" page.
Add a signIn callback that calls auth() and refuses the request when
the provider's purpose is account_linking and no session is present.
SSO providers and credentials login are unaffected.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>1 parent 8292882 commit 469060f
2 files changed
Lines changed: 39 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
12 | 12 | | |
13 | 13 | | |
14 | 14 | | |
| 15 | + | |
15 | 16 | | |
16 | 17 | | |
17 | 18 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
239 | 239 | | |
240 | 240 | | |
241 | 241 | | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
242 | 280 | | |
243 | 281 | | |
244 | 282 | | |
| |||
0 commit comments