mirror of
https://github.com/microsoft/vscode.git
synced 2026-04-25 19:18:59 +01:00
Fix #95879
This commit is contained in:
@@ -27,6 +27,7 @@ import { INotificationService, Severity } from 'vs/platform/notification/common/
|
||||
import { IDialogService } from 'vs/platform/dialogs/common/dialogs';
|
||||
import { IContextKey, IContextKeyService } from 'vs/platform/contextkey/common/contextkey';
|
||||
import { ICommandService } from 'vs/platform/commands/common/commands';
|
||||
import { Action } from 'vs/base/common/actions';
|
||||
|
||||
type UserAccountClassification = {
|
||||
id: { classification: 'EndUserPseudonymizedInformation', purpose: 'BusinessInsight' };
|
||||
@@ -137,11 +138,12 @@ export class UserDataSyncWorkbenchService extends Disposable implements IUserDat
|
||||
this.authenticationService.onDidRegisterAuthenticationProvider,
|
||||
this.authenticationService.onDidUnregisterAuthenticationProvider,
|
||||
), authenticationProviderId => this.isSupportedAuthenticationProviderId(authenticationProviderId)),
|
||||
this.userDataSyncAccountService.onTokenFailed)
|
||||
Event.filter(this.userDataSyncAccountService.onTokenFailed, isSuccessive => !isSuccessive))
|
||||
(() => this.update()));
|
||||
|
||||
this._register(Event.filter(this.authenticationService.onDidChangeSessions, e => this.isSupportedAuthenticationProviderId(e.providerId))(({ event }) => this.onDidChangeSessions(event)));
|
||||
this._register(this.storageService.onDidChangeStorage(e => this.onDidChangeStorage(e)));
|
||||
this._register(Event.filter(this.userDataSyncAccountService.onTokenFailed, isSuccessive => isSuccessive)(() => this.onDidSuccessiveAuthFailures()));
|
||||
}
|
||||
|
||||
private async update(): Promise<void> {
|
||||
@@ -201,10 +203,6 @@ export class UserDataSyncWorkbenchService extends Disposable implements IUserDat
|
||||
const previous = this._accountStatus;
|
||||
this.logService.debug('Sync account status changed', previous, accountStatus);
|
||||
|
||||
if (previous === AccountStatus.Available && accountStatus === AccountStatus.Unavailable) {
|
||||
this.turnoff(false);
|
||||
}
|
||||
|
||||
this._accountStatus = accountStatus;
|
||||
this.accountStatusContext.set(accountStatus);
|
||||
this._onDidChangeAccountStatus.fire(accountStatus);
|
||||
@@ -283,7 +281,7 @@ export class UserDataSyncWorkbenchService extends Disposable implements IUserDat
|
||||
return account.sessionId === this.currentSessionId;
|
||||
}
|
||||
|
||||
async pickAccount(): Promise<void> {
|
||||
async signIn(): Promise<void> {
|
||||
await this.pick();
|
||||
}
|
||||
|
||||
@@ -387,6 +385,20 @@ export class UserDataSyncWorkbenchService extends Disposable implements IUserDat
|
||||
await this.update();
|
||||
}
|
||||
|
||||
private async onDidSuccessiveAuthFailures(): Promise<void> {
|
||||
this.telemetryService.publicLog2('sync/successiveAuthFailures');
|
||||
this.currentSessionId = undefined;
|
||||
await this.update();
|
||||
|
||||
this.notificationService.notify({
|
||||
severity: Severity.Error,
|
||||
message: localize('successive auth failures', "Preferences sync was turned off because of successive authorization failures. Please sign in again to continue synchronizing"),
|
||||
actions: {
|
||||
primary: [new Action('sign in', localize('sign in', "Sign in"), undefined, true, () => this.signIn())]
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private onDidChangeSessions(e: AuthenticationSessionsChangeEvent): void {
|
||||
if (this.currentSessionId && e.removed.includes(this.currentSessionId)) {
|
||||
this.currentSessionId = undefined;
|
||||
|
||||
@@ -28,7 +28,7 @@ export interface IUserDataSyncWorkbenchService {
|
||||
|
||||
turnOn(): Promise<void>;
|
||||
turnoff(everyWhere: boolean): Promise<void>;
|
||||
pickAccount(): Promise<void>;
|
||||
signIn(): Promise<void>;
|
||||
}
|
||||
|
||||
export function getSyncAreaLabel(source: SyncResource): string {
|
||||
|
||||
@@ -7,7 +7,7 @@ import { IChannel } from 'vs/base/parts/ipc/common/ipc';
|
||||
import { ISharedProcessService } from 'vs/platform/ipc/electron-browser/sharedProcessService';
|
||||
import { registerSingleton } from 'vs/platform/instantiation/common/extensions';
|
||||
import { Disposable } from 'vs/base/common/lifecycle';
|
||||
import { Emitter, Event } from 'vs/base/common/event';
|
||||
import { Event, Emitter } from 'vs/base/common/event';
|
||||
import { IUserDataSyncAccountService, IUserDataSyncAccount } from 'vs/platform/userDataSync/common/userDataSyncAccount';
|
||||
|
||||
export class UserDataSyncAccountService extends Disposable implements IUserDataSyncAccountService {
|
||||
@@ -16,30 +16,32 @@ export class UserDataSyncAccountService extends Disposable implements IUserDataS
|
||||
|
||||
private readonly channel: IChannel;
|
||||
|
||||
private _token: IUserDataSyncAccount | undefined;
|
||||
get account(): IUserDataSyncAccount | undefined { return this._token; }
|
||||
private _onDidChangeToken = this._register(new Emitter<IUserDataSyncAccount | undefined>());
|
||||
readonly onDidChangeAccount = this._onDidChangeToken.event;
|
||||
private _account: IUserDataSyncAccount | undefined;
|
||||
get account(): IUserDataSyncAccount | undefined { return this._account; }
|
||||
|
||||
private _onTokenFailed: Emitter<void> = this._register(new Emitter<void>());
|
||||
readonly onTokenFailed: Event<void> = this._onTokenFailed.event;
|
||||
get onTokenFailed(): Event<boolean> { return this.channel.listen<boolean>('onTokenFailed'); }
|
||||
|
||||
private _onDidChangeAccount: Emitter<IUserDataSyncAccount | undefined> = this._register(new Emitter<IUserDataSyncAccount | undefined>());
|
||||
readonly onDidChangeAccount: Event<IUserDataSyncAccount | undefined> = this._onDidChangeAccount.event;
|
||||
|
||||
constructor(
|
||||
@ISharedProcessService sharedProcessService: ISharedProcessService,
|
||||
) {
|
||||
super();
|
||||
this.channel = sharedProcessService.getChannel('userDataSyncAccount');
|
||||
this._register(this.channel.listen<void[]>('onTokenFailed')(_ => this.sendTokenFailed()));
|
||||
this.channel.call<IUserDataSyncAccount | undefined>('_getInitialData').then(account => {
|
||||
this._account = account;
|
||||
this._register(this.channel.listen<IUserDataSyncAccount | undefined>('onDidChangeAccount')(account => {
|
||||
this._account = account;
|
||||
this._onDidChangeAccount.fire(account);
|
||||
}));
|
||||
});
|
||||
}
|
||||
|
||||
updateAccount(account: IUserDataSyncAccount | undefined): Promise<undefined> {
|
||||
this._token = account;
|
||||
return this.channel.call('updateAccount', account);
|
||||
}
|
||||
|
||||
sendTokenFailed(): void {
|
||||
this._onTokenFailed.fire();
|
||||
}
|
||||
}
|
||||
|
||||
registerSingleton(IUserDataSyncAccountService, UserDataSyncAccountService);
|
||||
|
||||
Reference in New Issue
Block a user