Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(login): allow refreshing token during bit login when already logged in #8758

Merged
merged 1 commit into from
Apr 8, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
17 changes: 16 additions & 1 deletion scopes/cloud/cloud/login.cmd.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,20 @@ export class LoginCmd implements Command {
): Promise<string> {
noBrowser = noBrowser || suppressBrowserLaunch;

const isLoggedIn = this.cloud.isLoggedIn();

if (isLoggedIn) {
this.cloud.logger.clearStatusLine();
const reLoginPrompt = chalk.yellow(
'You are already logged in. Do you want to re-login to refresh your access token? [yes(y)/no(n)]'
);
const ok = await yesno({ question: reLoginPrompt });
if (!ok) {
return chalk.green(`Logged in as ${this.cloud.getUsername()}`);
}
this.cloud.logout();
}

const result = await this.cloud.login(
port || this.port,
noBrowser,
Expand All @@ -58,9 +72,10 @@ export class LoginCmd implements Command {
undefined,
skipConfigUpdate
);

let message = chalk.green(`Logged in as ${result?.username}`);

if (result?.isAlreadyLoggedIn || skipConfigUpdate) {
if (skipConfigUpdate) {
return message;
}

Expand Down