From 4eb74cdeb44b964df7e1cc2654827dd49ceb558f Mon Sep 17 00:00:00 2001 From: Brandon Date: Wed, 25 Feb 2026 15:41:15 -0500 Subject: [PATCH] cleanup migration key for account, clean up --- src/app/tabs/settings.component.ts | 4 +++- .../state-service/stateMigration.service.ts | 24 +++++++------------ 2 files changed, 11 insertions(+), 17 deletions(-) diff --git a/src/app/tabs/settings.component.ts b/src/app/tabs/settings.component.ts index 0bff1466..d70c0ab3 100644 --- a/src/app/tabs/settings.component.ts +++ b/src/app/tabs/settings.component.ts @@ -55,7 +55,9 @@ export class SettingsComponent implements OnInit, OnDestroy { this.directory = await this.stateService.getDirectoryType(); this.ldap = (await this.stateService.getDirectory(DirectoryType.Ldap)) || this.ldap; - this.gsuite = await this.stateService.getDirectory(DirectoryType.GSuite); + this.gsuite = + (await this.stateService.getDirectory(DirectoryType.GSuite)) || + this.gsuite; this.entra = (await this.stateService.getDirectory(DirectoryType.EntraID)) || this.entra; diff --git a/src/services/state-service/stateMigration.service.ts b/src/services/state-service/stateMigration.service.ts index 28b6979b..17678d95 100644 --- a/src/services/state-service/stateMigration.service.ts +++ b/src/services/state-service/stateMigration.service.ts @@ -216,16 +216,8 @@ export class StateMigrationService { * the account and saved into flat keys for simpler access. */ protected async migrateStateFrom4To5(useSecureStorageForSecrets = true): Promise { - // Get the client_id (entity ID) which represents the authenticated user from login. - let userId = await this.get(ClientKeys.clientId); - - if (!userId) { - // No accounts to migrate, just update version - await this.set(StorageKeysVNext.stateVersion, StateVersion.Five); - return; - } - - const account = await this.get(userId); + const clientId = await this.storageService.get("activeUserId"); + const account = await this.get(clientId); if (!account) { // No account data found, just update version @@ -295,12 +287,12 @@ export class StateMigrationService { // Migrate secrets from {userId}_* to secret_* pattern if (useSecureStorageForSecrets) { const oldSecretKeys = [ - { old: `${userId}_${SecureStorageKeys.ldap}`, new: SecureStorageKeysVNext.ldap }, - { old: `${userId}_${SecureStorageKeys.gsuite}`, new: SecureStorageKeysVNext.gsuite }, - { old: `${userId}_${SecureStorageKeys.azure}`, new: SecureStorageKeysVNext.azure }, - { old: `${userId}_${SecureStorageKeys.entra}`, new: SecureStorageKeysVNext.entra }, - { old: `${userId}_${SecureStorageKeys.okta}`, new: SecureStorageKeysVNext.okta }, - { old: `${userId}_${SecureStorageKeys.oneLogin}`, new: SecureStorageKeysVNext.oneLogin }, + { old: `${clientId}_${SecureStorageKeys.ldap}`, new: SecureStorageKeysVNext.ldap }, + { old: `${clientId}_${SecureStorageKeys.gsuite}`, new: SecureStorageKeysVNext.gsuite }, + { old: `${clientId}_${SecureStorageKeys.azure}`, new: SecureStorageKeysVNext.azure }, + { old: `${clientId}_${SecureStorageKeys.entra}`, new: SecureStorageKeysVNext.entra }, + { old: `${clientId}_${SecureStorageKeys.okta}`, new: SecureStorageKeysVNext.okta }, + { old: `${clientId}_${SecureStorageKeys.oneLogin}`, new: SecureStorageKeysVNext.oneLogin }, ]; for (const { old: oldKey, new: newKey } of oldSecretKeys) {