Skip to content

Commit

Permalink
feat(login): allow refreshing token during bit login when already log…
Browse files Browse the repository at this point in the history
…ged in (#8758)
  • Loading branch information
luvkapur committed Apr 8, 2024
1 parent 148193c commit faa943a
Showing 1 changed file with 16 additions and 1 deletion.
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

0 comments on commit faa943a

Please sign in to comment.