Fix CLI OAuth login cookie cleanup#1606
Conversation
e410df6 to
e74b256
Compare
Greptile SummaryThis PR updates CLI OAuth login cleanup for legacy cookie sessions. The main changes are:
Confidence Score: 4/5The change is narrowly scoped, but the cookie cleanup ordering can still leave stale cookie data on the active token session. The modified OAuth login path and config helper are straightforward, and the remaining issue is localized to the ordering of cleanup operations. templates/cli/lib/auth/login.ts
What T-Rex did
Reviews (1): Last reviewed commit: "Fix CLI OAuth login cookie cleanup" | Re-trigger Greptile |
| globalConfig.removeCookie(); | ||
|
|
||
| const { removed: removedLegacySessions, failed: failedLegacySessions } = | ||
| await removeLegacySessionsExcept(id); |
There was a problem hiding this comment.
removeCookie() runs before removeLegacySessionsExcept(id), but legacy session revocation uses ClientLegacy.call(), which persists any a_session_console= Set-Cookie response back to the active global config. Since the new OAuth session is current during that cleanup, a logout response that expires or updates the legacy cookie can write a cookie field onto the new token session after it was removed. In that case login --new can still finish with stale cookie data in the newly created session.
| globalConfig.removeCookie(); | |
| const { removed: removedLegacySessions, failed: failedLegacySessions } = | |
| await removeLegacySessionsExcept(id); | |
| const { removed: removedLegacySessions, failed: failedLegacySessions } = | |
| await removeLegacySessionsExcept(id); | |
| globalConfig.removeCookie(); |
What does this PR do?
Fixes CLI OAuth device login so the newly created token-based session removes any legacy
cookievalue from the active CLI configuration.Previously,
appwrite login --newcould report that legacy cookie session data was removed while the new account entry still retained a stalecookiefield written during account verification.Test Plan
php example.php clicomposer refactor:checkcomposer lint-twigRelated Issue
#XXXX