Skip to content

Commit e74b256

Browse files
committed
Fix CLI OAuth login cookie cleanup
1 parent f0dc38c commit e74b256

2 files changed

Lines changed: 18 additions & 0 deletions

File tree

templates/cli/lib/auth/login.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -416,6 +416,7 @@ const loginWithOAuthDevice = async ({
416416
}
417417

418418
globalConfig.setEmail(account.email);
419+
globalConfig.removeCookie();
419420

420421
const { removed: removedLegacySessions, failed: failedLegacySessions } =
421422
await removeLegacySessionsExcept(id);

templates/cli/lib/config.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1345,6 +1345,10 @@ class Global extends Config<GlobalConfigData> {
13451345
this.setTo(Global.PREFERENCE_COOKIE, cookie);
13461346
}
13471347

1348+
removeCookie(): void {
1349+
this.deleteFrom(Global.PREFERENCE_COOKIE);
1350+
}
1351+
13481352
getProject(): string {
13491353
if (!this.hasFrom(Global.PREFERENCE_PROJECT)) {
13501354
return "";
@@ -1442,6 +1446,19 @@ class Global extends Config<GlobalConfigData> {
14421446
this.write();
14431447
}
14441448
}
1449+
1450+
deleteFrom(key: string): void {
1451+
const current = this.getCurrentSession();
1452+
1453+
if (current) {
1454+
const config = this.get(current as any);
1455+
1456+
if (config && (config as any)[key] !== undefined) {
1457+
delete (config as any)[key];
1458+
this.write();
1459+
}
1460+
}
1461+
}
14451462
}
14461463

14471464
export const localConfig = new Local();

0 commit comments

Comments
 (0)