diff --git a/extensions/github-authentication/package.json b/extensions/github-authentication/package.json index 7fcbc7f151c..cbc1ddc11dd 100644 --- a/extensions/github-authentication/package.json +++ b/extensions/github-authentication/package.json @@ -46,15 +46,6 @@ "description": "GitHub Enterprise Server URI" } } - }, - { - "title": "GitHub Authentication", - "properties": { - "github.experimental.multipleAccounts": { - "type": "boolean", - "description": "Experimental support for multiple GitHub accounts" - } - } } ] }, diff --git a/extensions/github-authentication/src/github.ts b/extensions/github-authentication/src/github.ts index 8a363d7dd33..d67fc99e08b 100644 --- a/extensions/github-authentication/src/github.ts +++ b/extensions/github-authentication/src/github.ts @@ -99,7 +99,6 @@ export class GitHubAuthenticationProvider implements vscode.AuthenticationProvid private readonly _keychain: Keychain; private readonly _accountsSeen = new Set(); private readonly _disposable: vscode.Disposable | undefined; - private _supportsMultipleAccounts = false; private _sessionsPromise: Promise; @@ -136,24 +135,10 @@ export class GitHubAuthenticationProvider implements vscode.AuthenticationProvid return sessions; }); - this._supportsMultipleAccounts = this._shouldSupportMultipleAccounts(); - this._disposable = vscode.Disposable.from( this._telemetryReporter, - vscode.authentication.registerAuthenticationProvider(type, this._githubServer.friendlyName, this, { supportsMultipleAccounts: this._supportsMultipleAccounts }), - this.context.secrets.onDidChange(() => this.checkForUpdates()), - vscode.workspace.onDidChangeConfiguration(async e => { - if (e.affectsConfiguration('github.experimental.multipleAccounts')) { - const newValue = this._shouldSupportMultipleAccounts(); - if (newValue === this._supportsMultipleAccounts) { - return; - } - const result = await vscode.window.showInformationMessage(vscode.l10n.t('Please reload the window to apply the new setting.'), { modal: true }, vscode.l10n.t('Reload Window')); - if (result) { - vscode.commands.executeCommand('workbench.action.reloadWindow'); - } - } - }) + vscode.authentication.registerAuthenticationProvider(type, this._githubServer.friendlyName, this, { supportsMultipleAccounts: true }), + this.context.secrets.onDidChange(() => this.checkForUpdates()) ); } @@ -251,9 +236,6 @@ export class GitHubAuthenticationProvider implements vscode.AuthenticationProvid const sessionPromises = sessionData.map(async (session: SessionData): Promise => { // For GitHub scope list, order doesn't matter so we immediately sort the scopes const scopesStr = [...session.scopes].sort().join(' '); - if (!this._supportsMultipleAccounts && scopesSeen.has(scopesStr)) { - return undefined; - } let userInfo: { id: string; accountName: string } | undefined; if (!session.account) { try { @@ -339,11 +321,7 @@ export class GitHubAuthenticationProvider implements vscode.AuthenticationProvid const session = await this.tokenToSession(token, scopes); this.afterSessionLoad(session); - const sessionIndex = sessions.findIndex( - this._supportsMultipleAccounts - ? s => s.account.id === session.account.id && arrayEquals([...s.scopes].sort(), sortedScopes) - : s => s.id === session.id || arrayEquals([...s.scopes].sort(), sortedScopes) - ); + const sessionIndex = sessions.findIndex(s => s.account.id === session.account.id && arrayEquals([...s.scopes].sort(), sortedScopes)); const removed = new Array(); if (sessionIndex > -1) { removed.push(...sessions.splice(sessionIndex, 1, session)); @@ -421,26 +399,4 @@ export class GitHubAuthenticationProvider implements vscode.AuthenticationProvid throw e; } } - - private _shouldSupportMultipleAccounts(): boolean { - // First check if there is a setting value to allow user to override the default - const inspect = vscode.workspace.getConfiguration('github.experimental').inspect('multipleAccounts'); - if (inspect?.workspaceFolderValue !== undefined) { - this._logger.trace(`Acquired multi-account enablement value from 'workspaceFolderValue'. Value: ${inspect.workspaceFolderValue}`); - return inspect.workspaceFolderValue; - } - if (inspect?.workspaceValue !== undefined) { - this._logger.trace(`Acquired multi-account enablement value from 'workspaceValue'. Value: ${inspect.workspaceValue}`); - return inspect.workspaceValue; - } - if (inspect?.globalValue !== undefined) { - this._logger.trace(`Acquired multi-account enablement value from 'globalValue'. Value: ${inspect.globalValue}`); - return inspect.globalValue; - } - - const value = vscode.env.uriScheme !== 'vscode'; - this._logger.trace(`Acquired multi-account enablement value from default. Value: ${value} because of uriScheme: ${vscode.env.uriScheme}`); - // If no setting or experiment value is found, default to false on stable and true on insiders - return value; - } }