Procházet zdrojové kódy

Adds prompt to clear GitLab authentication

main
Eric Amodio před 2 roky
rodič
revize
6545fed454
2 změnil soubory, kde provedl 30 přidání a 1 odebrání
  1. +24
    -0
      src/git/remotes/gitlab.ts
  2. +6
    -1
      src/git/remotes/provider.ts

+ 24
- 0
src/git/remotes/gitlab.ts Zobrazit soubor

@ -225,6 +225,30 @@ export class GitLabRemote extends RichRemoteProvider {
return super.connect();
}
@log()
override disconnect(silent: boolean = false): void {
super.disconnect(silent);
if (silent) return;
async function promptToClearAuthentication(this: GitLabRemote) {
const clear = { title: 'Clear Authentication' };
const cancel = { title: 'Cancel', isCloseAffordance: true };
const result = await window.showWarningMessage(
`Rich integration with GitLab as been disconnected.\n\nDo you also want to clear your saved authentication?`,
{ modal: true },
clear,
cancel,
);
if (result === clear) {
void Container.instance.integrationAuthentication.deleteSession(this.id, this.authDescriptor);
}
}
void promptToClearAuthentication.call(this);
}
async getLocalInfoFromRemoteUri(
repository: Repository,
uri: Uri,

+ 6
- 1
src/git/remotes/provider.ts Zobrazit soubor

@ -14,6 +14,7 @@ import { configuration } from '../../configuration';
import { Container } from '../../container';
import { AuthenticationError, ProviderRequestClientError } from '../../errors';
import { Logger } from '../../logger';
import type { IntegrationAuthenticationSessionDescriptor } from '../../plus/integrationAuthentication';
import { WorkspaceStorageKeys } from '../../storage';
import { gate } from '../../system/decorators/gate';
import { debug, log } from '../../system/decorators/log';
@ -303,6 +304,10 @@ export abstract class RichRemoteProvider extends RemoteProvider {
);
}
protected get authDescriptor(): IntegrationAuthenticationSessionDescriptor {
return { domain: this.domain, scopes: this.authProvider.scopes };
}
abstract get apiBaseUrl(): string;
protected abstract get authProvider(): { id: string; scopes: string[] };
@ -590,7 +595,7 @@ export abstract class RichRemoteProvider extends RemoteProvider {
if (container.integrationAuthentication.hasProvider(this.authProvider.id)) {
session = await container.integrationAuthentication.getSession(
this.authProvider.id,
{ domain: this.domain, scopes: this.authProvider.scopes },
this.authDescriptor,
{ createIfNeeded: createIfNeeded },
);
} else {

Načítá se…
Zrušit
Uložit