diff --git a/extensions/github-authentication/src/github.ts b/extensions/github-authentication/src/github.ts index 3d73bfb7656..c603455facf 100644 --- a/extensions/github-authentication/src/github.ts +++ b/extensions/github-authentication/src/github.ts @@ -11,7 +11,7 @@ import { PromiseAdapter, arrayEquals, promiseFromEvent } from './common/utils'; import { ExperimentationTelemetry } from './common/experimentationService'; import { Log } from './common/logger'; import { crypto } from './node/crypto'; -import { CANCELLATION_ERROR, TIMED_OUT_ERROR, USER_CANCELLATION_ERROR } from './common/errors'; +import { TIMED_OUT_ERROR, USER_CANCELLATION_ERROR } from './common/errors'; interface SessionData { id: string; @@ -298,42 +298,13 @@ export class GitHubAuthenticationProvider implements vscode.AuthenticationProvid const sessions = await this._sessionsPromise; + const accounts = new Set(sessions.map(session => session.account.label)); + const existingLogin = accounts.size <= 1 ? sessions[0]?.account.label : await vscode.window.showQuickPick([...accounts], { placeHolder: 'Choose an account that you would like to log in to' }); const scopeString = sortedScopes.join(' '); - const existingLogin = sessions[0]?.account.label; const token = await this._githubServer.login(scopeString, existingLogin); const session = await this.tokenToSession(token, scopes); this.afterSessionLoad(session); - if (sessions.some(s => s.account.id !== session.account.id)) { - const otherAccountsIndexes = new Array(); - const otherAccountsLabels = new Set(); - for (let i = 0; i < sessions.length; i++) { - if (sessions[i].account.id !== session.account.id) { - otherAccountsIndexes.push(i); - otherAccountsLabels.add(sessions[i].account.label); - } - } - const proceed = vscode.l10n.t("Continue"); - const labelstr = [...otherAccountsLabels].join(', '); - const result = await vscode.window.showInformationMessage( - vscode.l10n.t({ - message: "You are logged into another account already ({0}).\n\nDo you want to log out of that account and log in to '{1}' instead?", - comment: ['{0} is a comma-separated list of account names. {1} is the account name to log into.'], - args: [labelstr, session.account.label] - }), - { modal: true }, - proceed - ); - if (result !== proceed) { - throw new Error(CANCELLATION_ERROR); - } - - // Remove other accounts - for (const i of otherAccountsIndexes) { - sessions.splice(i, 1); - } - } - const sessionIndex = sessions.findIndex(s => s.id === session.id || arrayEquals([...s.scopes].sort(), sortedScopes)); if (sessionIndex > -1) { sessions.splice(sessionIndex, 1, session);