mirror of
https://github.com/laurent22/joplin.git
synced 2026-06-18 20:16:34 +02:00
Desktop: Fixed button to upgrade a master key
This commit is contained in:
1 parent
0de6e9ed11
commit
725c79d1ec
2 files changed
+15
-8
No files matched your search
@@ -198,14 +198,19 @@ export const useNeedMasterPassword = (passwordChecks: PasswordChecks, masterKeys
|
||||
return false;
|
||||
};
|
||||
|
||||
export const upgradeMasterKey = async (masterKey: MasterKeyEntity, passwordChecks: PasswordChecks, passwords: Record<string, string>): Promise<string> => {
|
||||
const passwordCheck = passwordChecks[masterKey.id];
|
||||
if (!passwordCheck) {
|
||||
export const determineKeyPassword = (masterKeyId: string, masterPasswordKeys: PasswordChecks, masterPassword: string, passwords: Record<string, string>): string => {
|
||||
if (masterPasswordKeys[masterKeyId]) return masterPassword;
|
||||
return passwords[masterKeyId];
|
||||
};
|
||||
|
||||
export const upgradeMasterKey = async (masterKey: MasterKeyEntity, password: string): Promise<string> => {
|
||||
if (!password) {
|
||||
return _('Please enter your password in the master key list below before upgrading the key.');
|
||||
}
|
||||
|
||||
try {
|
||||
const password = passwords[masterKey.id];
|
||||
// Just re-encrypt the master key, but using the new encryption method
|
||||
// (which would be the default).
|
||||
const newMasterKey = await EncryptionService.instance().reencryptMasterKey(masterKey, password, password);
|
||||
await MasterKey.save(newMasterKey);
|
||||
void reg.waitForSyncFinishedThenSync();
|
||||
|
||||
Reference in new issue
Block a user