This commit is contained in:
Sandeep Somavarapu
2020-06-09 13:21:30 +02:00
parent 8f70ac449e
commit d50b795e6b
8 changed files with 80 additions and 37 deletions

View File

@@ -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;