From 4d92c556745c9f8ccda923184d934b86c6f48127 Mon Sep 17 00:00:00 2001 From: Miguel Campos Date: Fri, 4 Oct 2024 09:18:24 -0700 Subject: [PATCH] always clear identity cache when logging in (#128) This PR removes a minor optimization which was causing an endless recursive loop, every time a user logs in we'll reset their identity cache. --- src/commands/login.ts | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/src/commands/login.ts b/src/commands/login.ts index 886203f..7c098c3 100644 --- a/src/commands/login.ts +++ b/src/commands/login.ts @@ -12,7 +12,6 @@ import { IDENTITY_CACHE_PATH, IDENTITY_FILE_PATH, authenticate, - loadCredentials, } from "../drivers/auth"; import { doc, guard } from "../drivers/firestore"; import { print2 } from "../drivers/stdio"; @@ -45,12 +44,8 @@ export const login = async ( if (!loginFn) throw "Unsupported login for your organization"; const tokenResponse = await loginFn(orgWithSlug); - // if the user changed their org, clear any cached identities this prevents - // commands like `aws assume role` from using the old identities - const currentIdentity = await loadCredentials().catch(() => undefined); - if (currentIdentity?.org.slug !== args.org) { - await clearIdentityCache(); - } + + await clearIdentityCache(); await writeIdentity(orgWithSlug, tokenResponse); // validate auth