Skip to content

Commit 32e4175

Browse files
committed
successful login also switches to that profile
1 parent 2568391 commit 32e4175

2 files changed

Lines changed: 16 additions & 2 deletions

File tree

.changeset/empty-dolls-judge.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"trigger.dev": patch
3+
---
4+
5+
Switch to profile after successful login

packages/cli-v3/src/commands/login.ts

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,11 @@ import {
1414
wrapCommandAction,
1515
} from "../cli/common.js";
1616
import { chalkLink, prettyError } from "../utilities/cliOutput.js";
17-
import { readAuthConfigProfile, writeAuthConfigProfile } from "../utilities/configFiles.js";
17+
import {
18+
readAuthConfigProfile,
19+
writeAuthConfigProfile,
20+
writeAuthConfigCurrentProfileName,
21+
} from "../utilities/configFiles.js";
1822
import { printInitialBanner } from "../utilities/initialBanner.js";
1923
import { LoginResult } from "../utilities/session.js";
2024
import { whoAmI } from "./whoami.js";
@@ -264,6 +268,11 @@ export async function login(options?: LoginOptions): Promise<LoginResult> {
264268
throw new Error(whoAmIResult.error);
265269
}
266270

271+
const profileName = options?.profile ?? "default";
272+
273+
// Set this profile as the current default
274+
writeAuthConfigCurrentProfileName(profileName);
275+
267276
if (opts.embedded) {
268277
log.step("Logged in successfully");
269278
} else {
@@ -274,7 +283,7 @@ export async function login(options?: LoginOptions): Promise<LoginResult> {
274283

275284
return {
276285
ok: true as const,
277-
profile: options?.profile ?? "default",
286+
profile: profileName,
278287
userId: whoAmIResult.data.userId,
279288
email: whoAmIResult.data.email,
280289
dashboardUrl: whoAmIResult.data.dashboardUrl,

0 commit comments

Comments
 (0)