All: When resetting the master password, also create a new master key with that password

This commit is contained in:
Laurent Cozic committed 2023-05-31 20:31:44 +01:00
1 parent 577aa519e0
commit e647775608
2 files changed
+9

No files matched your search

+5
View File
@@ -145,6 +145,11 @@ describe('e2ee/utils', () => {
expect(localSyncInfo().ppk.id).not.toBe(previousPpk.id);
expect(localSyncInfo().ppk.privateKey.ciphertext).not.toBe(previousPpk.privateKey.ciphertext);
expect(localSyncInfo().ppk.publicKey).not.toBe(previousPpk.publicKey);
// Also check that a new master key has been created, that it is active and enabled
expect(localSyncInfo().masterKeys.length).toBe(3);
expect(localSyncInfo().activeMasterKeyId).toBe(localSyncInfo().masterKeys[2].id);
expect(masterKeyEnabled(localSyncInfo().masterKeys[2])).toBe(true);
});
it('should fix active key selection issues - 1', async () => {
+4
View File
@@ -311,6 +311,10 @@ export async function resetMasterPassword(encryptionService: EncryptionService,
}
Setting.setValue('encryption.masterPassword', newPassword);
const masterKey = await encryptionService.generateMasterKey(newPassword);
await MasterKey.save(masterKey);
await loadMasterKeysFromSettings(encryptionService);
}
export enum MasterPasswordStatus {