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:
Oleg Demchenko 2021-06-10 13:14:08 -07:00 committed by GitHub
parent 32d29d7126
commit 61f34055fa
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 7 deletions

View file

@ -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" : { }
*/

View file

@ -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);
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);
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.`);
}
}