mirror of
https://github.com/Microsoft/vscode
synced 2024-09-13 13:46:13 +00:00
Auth session API fix (#125792)
* Adjust "provider is not registered" exception behavior * Process cancellation in GH auth provider `e.message` is always `undefined`
This commit is contained in:
parent
32d29d7126
commit
61f34055fa
|
@ -209,7 +209,7 @@ export class GitHubAuthenticationProvider implements vscode.AuthenticationProvid
|
|||
return session;
|
||||
} catch (e) {
|
||||
// If login was cancelled, do not notify user.
|
||||
if (e.message === 'Cancelled') {
|
||||
if (e === 'Cancelled') {
|
||||
/* __GDPR__
|
||||
"loginCancelled" : { }
|
||||
*/
|
||||
|
|
|
@ -713,19 +713,19 @@ export class AuthenticationService extends Disposable implements IAuthentication
|
|||
}
|
||||
|
||||
async getSessions(id: string, scopes?: string[], activateImmediate: boolean = false): Promise<ReadonlyArray<AuthenticationSession>> {
|
||||
try {
|
||||
const authProvider = this._authenticationProviders.get(id) || await this.tryActivateProvider(id, activateImmediate);
|
||||
if (authProvider) {
|
||||
return await authProvider.getSessions(scopes);
|
||||
} catch (_) {
|
||||
} else {
|
||||
throw new Error(`No authentication provider '${id}' is currently registered.`);
|
||||
}
|
||||
}
|
||||
|
||||
async createSession(id: string, scopes: string[], activateImmediate: boolean = false): Promise<AuthenticationSession> {
|
||||
try {
|
||||
const authProvider = this._authenticationProviders.get(id) || await this.tryActivateProvider(id, activateImmediate);
|
||||
if (authProvider) {
|
||||
return await authProvider.createSession(scopes);
|
||||
} catch (_) {
|
||||
} else {
|
||||
throw new Error(`No authentication provider '${id}' is currently registered.`);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue