Commit 26cebbe
committed
fix(sdk): defer loginWithToken auth-error cleanup to avoid racing fresh logins
The previous wrap cleared local credentials synchronously when DDPSDK's
auto-relogin on `connected` came back with an auth error. That fixed
the e2ee-key-reset flow (server force-logs out, SDK reconnects with
dead token, wrap clears creds, user falls back to Login) but raced
with concurrent fresh logins on:
- e2ee-passphrase-management :76/:87 (loginByUserState +
_pollStoredLoginToken inject a fresh token while the auto-retry
with the dead one is still in flight)
- saml :307 SLO (post-logout redirect chain rotates state under us)
Defer the cleanup by 500ms and re-verify the guards at the deadline.
If a concurrent fresh login completed in the meantime it will have
rotated either the stored token or sdk.account.uid; the deferred
check then bails out instead of nuking the just-stored credentials.
For genuine force-logout flows nothing else touches the state, so
the cleanup runs as before — just half a second later, well within
test timeouts.1 parent a940e3f commit 26cebbe
1 file changed
Lines changed: 15 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
236 | 236 | | |
237 | 237 | | |
238 | 238 | | |
239 | | - | |
240 | | - | |
241 | | - | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
242 | 253 | | |
243 | 254 | | |
244 | 255 | | |
| |||
251 | 262 | | |
252 | 263 | | |
253 | 264 | | |
254 | | - | |
| 265 | + | |
255 | 266 | | |
256 | 267 | | |
257 | 268 | | |
| |||
0 commit comments