mirror of
https://github.com/microsoft/vscode.git
synced 2026-08-15 02:07:31 +01:00
Have forceNewSession behave like createIfNone if no sessions are present (#148819)
* Have forceNewSession behave like createIfNone if no sessions are present * include note in vscode.d.ts about forceNewSesssion behavior
This commit is contained in:
@@ -210,9 +210,6 @@ export class MainThreadAuthentication extends Disposable implements MainThreadAu
|
||||
const supportsMultipleAccounts = this.authenticationService.supportsMultipleAccounts(providerId);
|
||||
|
||||
// Error cases
|
||||
if (options.forceNewSession && !sessions.length) {
|
||||
throw new Error('No existing sessions found.');
|
||||
}
|
||||
if (options.forceNewSession && options.createIfNone) {
|
||||
throw new Error('Invalid combination of options. Please remove one of the following: forceNewSession, createIfNone');
|
||||
}
|
||||
@@ -247,7 +244,11 @@ export class MainThreadAuthentication extends Disposable implements MainThreadAu
|
||||
if (options.createIfNone || options.forceNewSession) {
|
||||
const providerName = this.authenticationService.getLabel(providerId);
|
||||
const detail = (typeof options.forceNewSession === 'object') ? options.forceNewSession!.detail : undefined;
|
||||
const isAllowed = await this.loginPrompt(providerName, extensionName, !!options.forceNewSession, detail);
|
||||
|
||||
// We only want to show the "recreating session" prompt if we are using forceNewSession & there are sessions
|
||||
// that we will be "forcing through".
|
||||
const recreatingSession = !!(options.forceNewSession && sessions.length);
|
||||
const isAllowed = await this.loginPrompt(providerName, extensionName, recreatingSession, detail);
|
||||
if (!isAllowed) {
|
||||
throw new Error('User did not consent to login.');
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user