mirror of https://github.com/laurent22/joplin.git
All: When resetting the master password, also create a new master key with that password
parent
577aa519e0
commit
e647775608
|
@ -145,6 +145,11 @@ describe('e2ee/utils', () => {
|
||||||
expect(localSyncInfo().ppk.id).not.toBe(previousPpk.id);
|
expect(localSyncInfo().ppk.id).not.toBe(previousPpk.id);
|
||||||
expect(localSyncInfo().ppk.privateKey.ciphertext).not.toBe(previousPpk.privateKey.ciphertext);
|
expect(localSyncInfo().ppk.privateKey.ciphertext).not.toBe(previousPpk.privateKey.ciphertext);
|
||||||
expect(localSyncInfo().ppk.publicKey).not.toBe(previousPpk.publicKey);
|
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 () => {
|
it('should fix active key selection issues - 1', async () => {
|
||||||
|
|
|
@ -311,6 +311,10 @@ export async function resetMasterPassword(encryptionService: EncryptionService,
|
||||||
}
|
}
|
||||||
|
|
||||||
Setting.setValue('encryption.masterPassword', newPassword);
|
Setting.setValue('encryption.masterPassword', newPassword);
|
||||||
|
|
||||||
|
const masterKey = await encryptionService.generateMasterKey(newPassword);
|
||||||
|
await MasterKey.save(masterKey);
|
||||||
|
await loadMasterKeysFromSettings(encryptionService);
|
||||||
}
|
}
|
||||||
|
|
||||||
export enum MasterPasswordStatus {
|
export enum MasterPasswordStatus {
|
||||||
|
|
Loading…
Reference in New Issue