Skip to content

Commit fc9543a

Browse files
author
Rachel Macfarlane
authored
Reset settings sync token on 401, fixes microsoft#91653 (microsoft#91726)
1 parent d685711 commit fc9543a

1 file changed

Lines changed: 11 additions & 1 deletion

File tree

src/vs/workbench/contrib/userDataSync/browser/userDataSync.ts

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ export class UserDataSyncWorkbenchContribution extends Disposable implements IWo
155155
this._register(Event.debounce(userDataSyncService.onDidChangeStatus, () => undefined, 500)(() => this.onDidChangeSyncStatus(this.userDataSyncService.status)));
156156
this._register(userDataSyncService.onDidChangeConflicts(() => this.onDidChangeConflicts(this.userDataSyncService.conflictsSources)));
157157
this._register(userDataSyncService.onSyncErrors(errors => this.onSyncErrors(errors)));
158-
this._register(this.authTokenService.onTokenFailed(_ => this.authenticationService.getSessions(this.userDataSyncStore!.authenticationProviderId)));
158+
this._register(this.authTokenService.onTokenFailed(_ => this.onTokenFailed()));
159159
this._register(this.userDataSyncEnablementService.onDidChangeEnablement(enabled => this.onDidChangeEnablement(enabled)));
160160
this._register(this.authenticationService.onDidRegisterAuthenticationProvider(e => this.onDidRegisterAuthenticationProvider(e)));
161161
this._register(this.authenticationService.onDidUnregisterAuthenticationProvider(e => this.onDidUnregisterAuthenticationProvider(e)));
@@ -255,6 +255,16 @@ export class UserDataSyncWorkbenchContribution extends Disposable implements IWo
255255
}
256256
}
257257

258+
private async onTokenFailed(): Promise<void> {
259+
if (this.activeAccount) {
260+
const accounts = (await this.authenticationService.getSessions(this.userDataSyncStore!.authenticationProviderId) || []);
261+
const matchingAccount = accounts.filter(a => a.id === this.activeAccount?.id)[0];
262+
this.setActiveAccount(matchingAccount);
263+
} else {
264+
this.setActiveAccount(undefined);
265+
}
266+
}
267+
258268
private async onDidRegisterAuthenticationProvider(providerId: string) {
259269
if (providerId === this.userDataSyncStore!.authenticationProviderId) {
260270
await this.initializeActiveAccount();

0 commit comments

Comments
 (0)