Skip to content

Commit 44d8dca

Browse files
Copilotalexr00
andcommitted
Add Reauthenticate button to SAML error messages
Co-authored-by: alexr00 <[email protected]>
1 parent 07e7ce4 commit 44d8dca

1 file changed

Lines changed: 26 additions & 2 deletions

File tree

src/github/folderRepositoryManager.ts

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -534,12 +534,36 @@ export class FolderRepositoryManager extends Disposable {
534534
const stillMissing = result.canceled ? missingSaml : samlTest.map((result, index) => !result ? missingSaml[index] : undefined).filter((repo): repo is GitHubRepository => !!repo);
535535
// Make a test call to see if the user has SAML enabled.
536536
if (stillMissing.length > 0) {
537+
const reauthenticate = vscode.l10n.t('Reauthenticate');
537538
if (stillMissing.length === repositories.length) {
538-
await vscode.window.showErrorMessage(vscode.l10n.t('SAML access was not provided. GitHub Pull Requests will not work.'), { modal: true });
539+
const choice = await vscode.window.showErrorMessage(vscode.l10n.t('SAML access was not provided. GitHub Pull Requests will not work.'), { modal: true }, reauthenticate);
540+
if (choice === reauthenticate) {
541+
const retryResult = await this._credentialStore.showSamlMessageAndAuth(stillMissing.map(repo => repo.remote.owner));
542+
if (!retryResult.canceled) {
543+
const retryTest = await Promise.all(stillMissing.map(repo => repo.resolveRemote()));
544+
const stillMissingAfterRetry = retryTest.map((result, index) => !result ? stillMissing[index] : undefined).filter((repo): repo is GitHubRepository => !!repo);
545+
if (stillMissingAfterRetry.length === 0) {
546+
// Success! Continue with initialization
547+
return false;
548+
}
549+
}
550+
}
539551
this.dispose();
540552
return true;
541553
}
542-
await vscode.window.showErrorMessage(vscode.l10n.t('SAML access was not provided. Some GitHub repositories will not be available.'), { modal: true });
554+
const choice = await vscode.window.showErrorMessage(vscode.l10n.t('SAML access was not provided. Some GitHub repositories will not be available.'), { modal: true }, reauthenticate);
555+
if (choice === reauthenticate) {
556+
const retryResult = await this._credentialStore.showSamlMessageAndAuth(stillMissing.map(repo => repo.remote.owner));
557+
if (!retryResult.canceled) {
558+
const retryTest = await Promise.all(stillMissing.map(repo => repo.resolveRemote()));
559+
const stillMissingAfterRetry = retryTest.map((result, index) => !result ? stillMissing[index] : undefined).filter((repo): repo is GitHubRepository => !!repo);
560+
if (stillMissingAfterRetry.length < stillMissing.length) {
561+
// Some repos now have access, update stillMissing
562+
cleanUpMissingSaml(stillMissingAfterRetry);
563+
return false;
564+
}
565+
}
566+
}
543567
cleanUpMissingSaml(stillMissing);
544568
}
545569
}

0 commit comments

Comments
 (0)