Skip to content

Commit 329dc0e

Browse files
committed
Update the default org when logging in
1 parent f2d274f commit 329dc0e

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/commands/login/attempt-login.mts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import {
1010
getConfigValueOrUndef,
1111
isReadOnlyConfig,
1212
isTestingV1,
13+
updateConfigValue,
1314
} from '../../utils/config.mts'
1415
import { failMsgWithBadge } from '../../utils/fail-msg-with-badge.mts'
1516
import { setupSdk } from '../../utils/sdk.mts'
@@ -61,8 +62,9 @@ export async function attemptLogin(
6162
}
6263

6364
const orgs: SocketSdkReturnType<'getOrganizations'>['data'] = result.data
65+
const orgSlugs = Object.values(orgs.organizations).map(obj => obj.slug)
6466

65-
logger.success(`API key verified: ${Object.values(orgs.organizations)}`)
67+
logger.success(`API key verified: ${orgSlugs}`)
6668

6769
const enforcedChoices: OrgChoices = Object.values(orgs.organizations)
6870
.filter(org => org?.plan === 'enterprise')
@@ -141,6 +143,8 @@ export async function attemptLogin(
141143
}
142144
}
143145

146+
updateConfigValue('defaultOrg', orgSlugs[0])
147+
144148
const previousPersistedToken = getConfigValueOrUndef('apiToken')
145149
try {
146150
applyLogin(apiToken, enforcedOrgs, apiBaseUrl, apiProxy)

0 commit comments

Comments
 (0)