1
0
mirror of https://github.com/bitwarden/browser synced 2025-12-10 13:23:34 +00:00

[PM-27342] Fix state migration (#17018)

* Fix migration

* Update test
This commit is contained in:
Thomas Avery
2025-10-27 09:55:31 -05:00
committed by GitHub
parent ea4b6779a5
commit fd45689745
2 changed files with 13 additions and 1 deletions

View File

@@ -97,6 +97,18 @@ describe("AddMasterPasswordUnlockData", () => {
user_user1_kdfConfig_kdfConfig: { kdfType: 0, iterations: 600000 }, user_user1_kdfConfig_kdfConfig: { kdfType: 0, iterations: 600000 },
}); });
}); });
it("handles users with missing global accounts", async () => {
const output = await runMigrator(sut, {
global_account_accounts: { user_user1: null },
user_user1_kdfConfig_kdfConfig: { kdfType: 0, iterations: 600000 },
});
expect(output).toEqual({
global_account_accounts: { user_user1: null },
user_user1_kdfConfig_kdfConfig: { kdfType: 0, iterations: 600000 },
});
});
}); });
describe("rollback", () => { describe("rollback", () => {

View File

@@ -32,7 +32,7 @@ type Account = {
export class AddMasterPasswordUnlockData extends Migrator<72, 73> { export class AddMasterPasswordUnlockData extends Migrator<72, 73> {
async migrate(helper: MigrationHelper): Promise<void> { async migrate(helper: MigrationHelper): Promise<void> {
async function migrateAccount(userId: string, account: Account) { async function migrateAccount(userId: string, account: Account) {
const email = account.email; const email = account?.email;
const kdfConfig = await helper.getFromUser(userId, KDF_CONFIG_DISK); const kdfConfig = await helper.getFromUser(userId, KDF_CONFIG_DISK);
const masterKeyEncryptedUserKey = await helper.getFromUser( const masterKeyEncryptedUserKey = await helper.getFromUser(
userId, userId,