mirror of
https://github.com/microsoft/vscode.git
synced 2025-12-10 00:27:05 -06:00
parent
e605ba270d
commit
d226599bae
@ -15,7 +15,7 @@ import { IContextKey, IContextKeyService, RawContextKey } from '../../../../plat
|
||||
import { Action2, registerAction2 } from '../../../../platform/actions/common/actions.js';
|
||||
import { localize } from '../../../../nls.js';
|
||||
import { IWorkbenchContribution, registerWorkbenchContribution2, WorkbenchPhase } from '../../../common/contributions.js';
|
||||
import { Barrier } from '../../../../base/common/async.js';
|
||||
import { Barrier, timeout } from '../../../../base/common/async.js';
|
||||
import { IConfigurationService } from '../../../../platform/configuration/common/configuration.js';
|
||||
import { getErrorMessage } from '../../../../base/common/errors.js';
|
||||
import { IDefaultAccount } from '../../../../base/common/defaultAccount.js';
|
||||
@ -251,7 +251,7 @@ export class DefaultAccountManagementContribution extends Disposable implements
|
||||
}
|
||||
|
||||
private async findMatchingProviderSession(authProviderId: string, allScopes: string[][]): Promise<AuthenticationSession | undefined> {
|
||||
const sessions = await this.authenticationService.getSessions(authProviderId, undefined, undefined, true);
|
||||
const sessions = await this.getSessions(authProviderId);
|
||||
for (const session of sessions) {
|
||||
this.logService.debug('[DefaultAccount] Checking session with scopes', session.scopes);
|
||||
for (const scopes of allScopes) {
|
||||
@ -263,6 +263,21 @@ export class DefaultAccountManagementContribution extends Disposable implements
|
||||
return undefined;
|
||||
}
|
||||
|
||||
private async getSessions(authProviderId: string): Promise<readonly AuthenticationSession[]> {
|
||||
for (let attempt = 1; attempt <= 3; attempt++) {
|
||||
try {
|
||||
return await this.authenticationService.getSessions(authProviderId, undefined, undefined, true);
|
||||
} catch (error) {
|
||||
this.logService.warn(`[DefaultAccount] Attempt ${attempt} to get sessions failed:`, getErrorMessage(error));
|
||||
if (attempt === 3) {
|
||||
throw error;
|
||||
}
|
||||
await timeout(500);
|
||||
}
|
||||
}
|
||||
throw new Error('Unable to get sessions after multiple attempts');
|
||||
}
|
||||
|
||||
private scopesMatch(scopes: ReadonlyArray<string>, expectedScopes: string[]): boolean {
|
||||
return scopes.length === expectedScopes.length && expectedScopes.every(scope => scopes.includes(scope));
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user