From 9b0e5ae4563d1680d117e414e8bae1a977639ef1 Mon Sep 17 00:00:00 2001 From: Addison Beck Date: Fri, 21 Jan 2022 12:41:15 -0500 Subject: [PATCH] [bug] Address existing data & defaults when migrating from an unauthenticated state (#626) --- common/src/services/state.service.ts | 1 + common/src/services/stateMigration.service.ts | 6 ++++++ 2 files changed, 7 insertions(+) diff --git a/common/src/services/state.service.ts b/common/src/services/state.service.ts index 49d5ab1164e..446b9fde781 100644 --- a/common/src/services/state.service.ts +++ b/common/src/services/state.service.ts @@ -2219,6 +2219,7 @@ export class StateService await this.storageService.remove(keys.tempAccountSettings); } account.settings.environmentUrls = environmentUrls; + Object.assign(account.settings, this.createAccount().settings); await this.storageService.save( account.profile.userId, account, diff --git a/common/src/services/stateMigration.service.ts b/common/src/services/stateMigration.service.ts index ddc191aeda3..ec2a0986d4e 100644 --- a/common/src/services/stateMigration.service.ts +++ b/common/src/services/stateMigration.service.ts @@ -193,6 +193,12 @@ export class StateMigrationService { alwaysShowDock: await this.get(v1Keys.alwaysShowDock), }; + // Some processes, like biometrics, may have already defined a value before migrations are run + const existingGlobals = await this.get(keys.global); + if (existingGlobals != null) { + Object.assign(globals, existingGlobals); + } + const userId = (await this.get(v1Keys.userId)) ?? (await this.get(v1Keys.entityId));