Skip to content

Commit 7fa7cbf

Browse files
committed
Improve fallback logic for getSession
Fixes #3500
1 parent 7fd570d commit 7fa7cbf

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

src/github/credentials.ts

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -260,9 +260,24 @@ export class CredentialStore implements vscode.Disposable {
260260

261261
private async getSession(authProviderId: AuthProvider, getAuthSessionOptions: vscode.AuthenticationGetSessionOptions) {
262262
let session: vscode.AuthenticationSession | undefined = await vscode.authentication.getSession(authProviderId, SCOPES, { silent: true });
263-
if (!session) {
263+
if (session) {
264+
return session;
265+
}
266+
267+
if (getAuthSessionOptions.createIfNone) {
268+
const silent = getAuthSessionOptions.silent;
269+
getAuthSessionOptions.createIfNone = false;
270+
getAuthSessionOptions.silent = true;
271+
session = await vscode.authentication.getSession(authProviderId, SCOPES_OLD, getAuthSessionOptions);
272+
if (!session) {
273+
getAuthSessionOptions.createIfNone = true;
274+
getAuthSessionOptions.silent = silent;
275+
session = await vscode.authentication.getSession(authProviderId, SCOPES, getAuthSessionOptions);
276+
}
277+
} else {
264278
session = await vscode.authentication.getSession(authProviderId, SCOPES_OLD, getAuthSessionOptions);
265279
}
280+
266281
return session;
267282
}
268283

0 commit comments

Comments
 (0)