fix: delete legacy auth.json after migration to prevent stale token overwrites (#363)
parent
ea7836afad
commit
4f10279ac3
|
|
@ -305,6 +305,18 @@ export function ensureAuthProfileStore(agentDir?: string): AuthProfileStore {
|
||||||
if (shouldWrite) {
|
if (shouldWrite) {
|
||||||
saveJsonFile(authPath, store);
|
saveJsonFile(authPath, store);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Delete legacy auth.json after successful migration to prevent stale tokens
|
||||||
|
// from being re-migrated and overwriting fresh credentials (fixes #363)
|
||||||
|
if (legacy !== null) {
|
||||||
|
const legacyPath = resolveLegacyAuthStorePath(agentDir);
|
||||||
|
try {
|
||||||
|
fs.unlinkSync(legacyPath);
|
||||||
|
} catch {
|
||||||
|
// Ignore if already deleted or permission issues
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return store;
|
return store;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue