瀏覽代碼

Adds prompt to clear GitLab authentication

main
Eric Amodio 2 年之前
父節點
當前提交
6545fed454
共有 2 個檔案被更改,包括 30 行新增1 行删除
  1. +24
    -0
      src/git/remotes/gitlab.ts
  2. +6
    -1
      src/git/remotes/provider.ts

+ 24
- 0
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,

+ 6
- 1
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 {

Loading…
取消
儲存