Skip to content

Commit 87287d0

Browse files
author
Rachel Macfarlane
committed
Code cleanup, remove stuff related to sign in commands
1 parent bb34501 commit 87287d0

6 files changed

Lines changed: 13 additions & 40 deletions

File tree

extensions/github-authentication/src/extension.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,12 @@ export async function activate(context: vscode.ExtensionContext) {
2121
vscode.authentication.registerAuthenticationProvider({
2222
id: 'github',
2323
displayName: 'GitHub',
24-
supportsMultipleAccounts: false,
2524
onDidChangeSessions: onDidChangeSessions.event,
2625
getSessions: () => Promise.resolve(loginService.sessions),
27-
login: async (scopeList: string[] | undefined) => {
26+
login: async (scopeList: string[]) => {
2827
try {
2928
telemetryReporter.sendTelemetryEvent('login');
30-
const loginScopes = scopeList ? scopeList.sort().join(' ') : 'user:email';
31-
const session = await loginService.login(loginScopes);
29+
const session = await loginService.login(scopeList.sort().join(' '));
3230
Logger.info('Login success!');
3331
onDidChangeSessions.fire({ added: [session.id], removed: [], changed: [] });
3432
return session;

extensions/vscode-account/src/extension.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,12 @@ export async function activate(context: vscode.ExtensionContext) {
2323
context.subscriptions.push(vscode.authentication.registerAuthenticationProvider({
2424
id: 'microsoft',
2525
displayName: 'Microsoft',
26-
supportsMultipleAccounts: true,
2726
onDidChangeSessions: onDidChangeSessions.event,
2827
getSessions: () => Promise.resolve(loginService.sessions),
29-
login: async (scopes: string[] | undefined) => {
28+
login: async (scopes: string[]) => {
3029
try {
3130
telemetryReporter.sendTelemetryEvent('login');
32-
const loginScopes = scopes ? scopes.sort().join(' ') : 'https://management.core.windows.net/.default offline_access';
33-
await loginService.login(loginScopes);
31+
await loginService.login(scopes.sort().join(' '));
3432
const session = loginService.sessions[loginService.sessions.length - 1];
3533
onDidChangeSessions.fire({ added: [session.id], removed: [], changed: [] });
3634
return loginService.sessions[0]!;

src/vs/vscode.proposed.d.ts

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -74,12 +74,6 @@ declare module 'vscode' {
7474
readonly id: string;
7575
readonly displayName: string;
7676

77-
/**
78-
* Whether the authentication provider supports the user being logged into
79-
* multiple different accounts at the same time.
80-
*/
81-
supportsMultipleAccounts: boolean;
82-
8377
/**
8478
* An [event](#Event) which fires when the array of sessions has changed, or data
8579
* within a session has changed.
@@ -94,7 +88,7 @@ declare module 'vscode' {
9488
/**
9589
* Prompts a user to login.
9690
*/
97-
login(scopes?: string[]): Thenable<AuthenticationSession>;
91+
login(scopes: string[]): Thenable<AuthenticationSession>;
9892
logout(sessionId: string): Thenable<void>;
9993
}
10094

src/vs/workbench/api/browser/mainThreadAuthentication.ts

Lines changed: 4 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import { ExtHostAuthenticationShape, ExtHostContext, IExtHostContext, MainContex
1212
import { IDialogService } from 'vs/platform/dialogs/common/dialogs';
1313
import { IStorageService, StorageScope } from 'vs/platform/storage/common/storage';
1414
import Severity from 'vs/base/common/severity';
15-
import { MenuRegistry, MenuId, IMenuItem } from 'vs/platform/actions/common/actions';
15+
import { MenuRegistry, MenuId } from 'vs/platform/actions/common/actions';
1616
import { CommandsRegistry } from 'vs/platform/commands/common/commands';
1717
import { IQuickInputService } from 'vs/platform/quickinput/common/quickInput';
1818
import { INotificationService } from 'vs/platform/notification/common/notification';
@@ -57,14 +57,11 @@ export class MainThreadAuthenticationProvider extends Disposable {
5757
private _sessionMenuItems = new Map<string, IDisposable[]>();
5858
private _accounts = new Map<string, string[]>(); // Map account name to session ids
5959
private _sessions = new Map<string, string>(); // Map account id to name
60-
private _signInMenuItem: IMenuItem | undefined;
61-
private _signInMenuDisposables: IDisposable[] = [];
6260

6361
constructor(
6462
private readonly _proxy: ExtHostAuthenticationShape,
6563
public readonly id: string,
6664
public readonly displayName: string,
67-
private readonly supportsMultipleAccounts: boolean,
6865
private readonly notificationService: INotificationService
6966
) {
7067
super();
@@ -248,27 +245,14 @@ export class MainThreadAuthenticationProvider extends Disposable {
248245
this._sessionMenuItems.delete(accountName);
249246
}
250247
this._accounts.delete(accountName);
251-
252-
if (this._signInMenuItem) {
253-
this._signInMenuItem.command.title = nls.localize('addAccount', "Sign in to {0}", this.displayName);
254-
}
255248
}
256249
}
257250
});
258251

259252
addedSessions.forEach(session => this.registerSession(session));
260-
261-
if (addedSessions.length && this._signInMenuItem) {
262-
if (this.supportsMultipleAccounts) {
263-
this._signInMenuItem.command.title = nls.localize('addAnotherAccount', "Sign in to another {0} account", this.displayName);
264-
} else {
265-
this._signInMenuDisposables.forEach(item => item.dispose());
266-
this._signInMenuItem = undefined;
267-
}
268-
}
269253
}
270254

271-
login(scopes?: string[]): Promise<modes.AuthenticationSession> {
255+
login(scopes: string[]): Promise<modes.AuthenticationSession> {
272256
return this._proxy.$login(this.id, scopes).then(session => {
273257
return {
274258
id: session.id,
@@ -287,7 +271,6 @@ export class MainThreadAuthenticationProvider extends Disposable {
287271
super.dispose();
288272
this._sessionMenuItems.forEach(item => item.forEach(d => d.dispose()));
289273
this._sessionMenuItems.clear();
290-
this._signInMenuDisposables.forEach(item => item.dispose());
291274
}
292275
}
293276

@@ -306,8 +289,8 @@ export class MainThreadAuthentication extends Disposable implements MainThreadAu
306289
this._proxy = extHostContext.getProxy(ExtHostContext.ExtHostAuthentication);
307290
}
308291

309-
async $registerAuthenticationProvider(id: string, displayName: string, supportsMultipleAccounts: boolean): Promise<void> {
310-
const provider = new MainThreadAuthenticationProvider(this._proxy, id, displayName, supportsMultipleAccounts, this.notificationService);
292+
async $registerAuthenticationProvider(id: string, displayName: string): Promise<void> {
293+
const provider = new MainThreadAuthenticationProvider(this._proxy, id, displayName, this.notificationService);
311294
await provider.initialize();
312295
this.authenticationService.registerAuthenticationProvider(id, provider);
313296
}

src/vs/workbench/api/common/extHost.protocol.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ export interface MainThreadCommentsShape extends IDisposable {
155155
}
156156

157157
export interface MainThreadAuthenticationShape extends IDisposable {
158-
$registerAuthenticationProvider(id: string, displayName: string, supportsMultipleAccounts: boolean): void;
158+
$registerAuthenticationProvider(id: string, displayName: string): void;
159159
$unregisterAuthenticationProvider(id: string): void;
160160
$onDidChangeSessions(providerId: string, event: modes.AuthenticationSessionsChangeEvent): void;
161161
$getSessionsPrompt(providerId: string, accountName: string, providerName: string, extensionId: string, extensionName: string): Promise<boolean>;
@@ -998,7 +998,7 @@ export interface ExtHostLabelServiceShape {
998998
export interface ExtHostAuthenticationShape {
999999
$getSessions(id: string): Promise<ReadonlyArray<modes.AuthenticationSession>>;
10001000
$getSessionAccessToken(id: string, sessionId: string): Promise<string>;
1001-
$login(id: string, scopes: string[] | undefined): Promise<modes.AuthenticationSession>;
1001+
$login(id: string, scopes: string[]): Promise<modes.AuthenticationSession>;
10021002
$logout(id: string, sessionId: string): Promise<void>;
10031003
}
10041004

src/vs/workbench/api/common/extHostAuthentication.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ export class ExtHostAuthentication implements ExtHostAuthenticationShape {
114114
this._onDidChangeSessions.fire({ [provider.id]: e });
115115
});
116116

117-
this._proxy.$registerAuthenticationProvider(provider.id, provider.displayName, provider.supportsMultipleAccounts);
117+
this._proxy.$registerAuthenticationProvider(provider.id, provider.displayName);
118118
this._onDidChangeAuthenticationProviders.fire({ added: [provider.id], removed: [] });
119119

120120
return new Disposable(() => {
@@ -125,7 +125,7 @@ export class ExtHostAuthentication implements ExtHostAuthenticationShape {
125125
});
126126
}
127127

128-
$login(providerId: string, scopes: string[] | undefined): Promise<modes.AuthenticationSession> {
128+
$login(providerId: string, scopes: string[]): Promise<modes.AuthenticationSession> {
129129
const authProvider = this._authenticationProviders.get(providerId);
130130
if (authProvider) {
131131
return Promise.resolve(authProvider.login(scopes));

0 commit comments

Comments
 (0)