diff --git a/src/git/remotes/gitlab.ts b/src/git/remotes/gitlab.ts index 96247a0..6b14a82 100644 --- a/src/git/remotes/gitlab.ts +++ b/src/git/remotes/gitlab.ts @@ -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, diff --git a/src/git/remotes/provider.ts b/src/git/remotes/provider.ts index 177a533..d9d08f2 100644 --- a/src/git/remotes/provider.ts +++ b/src/git/remotes/provider.ts @@ -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 {