From fc9543ac88a6ddd541d319d6425e1734ccb36f72 Mon Sep 17 00:00:00 2001 From: Rachel Macfarlane Date: Fri, 28 Feb 2020 16:03:12 -0800 Subject: [PATCH] Reset settings sync token on 401, fixes #91653 (#91726) --- .../contrib/userDataSync/browser/userDataSync.ts | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/vs/workbench/contrib/userDataSync/browser/userDataSync.ts b/src/vs/workbench/contrib/userDataSync/browser/userDataSync.ts index 0a30e149ade..403c7e046bd 100644 --- a/src/vs/workbench/contrib/userDataSync/browser/userDataSync.ts +++ b/src/vs/workbench/contrib/userDataSync/browser/userDataSync.ts @@ -155,7 +155,7 @@ export class UserDataSyncWorkbenchContribution extends Disposable implements IWo this._register(Event.debounce(userDataSyncService.onDidChangeStatus, () => undefined, 500)(() => this.onDidChangeSyncStatus(this.userDataSyncService.status))); this._register(userDataSyncService.onDidChangeConflicts(() => this.onDidChangeConflicts(this.userDataSyncService.conflictsSources))); this._register(userDataSyncService.onSyncErrors(errors => this.onSyncErrors(errors))); - this._register(this.authTokenService.onTokenFailed(_ => this.authenticationService.getSessions(this.userDataSyncStore!.authenticationProviderId))); + this._register(this.authTokenService.onTokenFailed(_ => this.onTokenFailed())); this._register(this.userDataSyncEnablementService.onDidChangeEnablement(enabled => this.onDidChangeEnablement(enabled))); this._register(this.authenticationService.onDidRegisterAuthenticationProvider(e => this.onDidRegisterAuthenticationProvider(e))); this._register(this.authenticationService.onDidUnregisterAuthenticationProvider(e => this.onDidUnregisterAuthenticationProvider(e))); @@ -255,6 +255,16 @@ export class UserDataSyncWorkbenchContribution extends Disposable implements IWo } } + private async onTokenFailed(): Promise { + if (this.activeAccount) { + const accounts = (await this.authenticationService.getSessions(this.userDataSyncStore!.authenticationProviderId) || []); + const matchingAccount = accounts.filter(a => a.id === this.activeAccount?.id)[0]; + this.setActiveAccount(matchingAccount); + } else { + this.setActiveAccount(undefined); + } + } + private async onDidRegisterAuthenticationProvider(providerId: string) { if (providerId === this.userDataSyncStore!.authenticationProviderId) { await this.initializeActiveAccount(); -- GitLab