1
0
mirror of https://github.com/laurent22/joplin.git synced 2025-06-27 23:28:38 +02:00

Desktop: Improved master password state handling in Encryption screen

This commit is contained in:
Laurent Cozic
2021-10-17 19:08:34 +01:00
parent 8d09ed3bac
commit 7d62df8906
3 changed files with 15 additions and 4 deletions

View File

@ -188,6 +188,16 @@ export const usePasswordChecker = (masterKeys: MasterKeyEntity[], activeMasterKe
return { passwordChecks, masterPasswordKeys, masterPasswordStatus };
};
export const useNeedMasterPassword = (passwordChecks: PasswordChecks, masterKeys: MasterKeyEntity[]) => {
for (const [mkId, valid] of Object.entries(passwordChecks)) {
const mk = masterKeys.find(mk => mk.id === mkId);
if (!mk) continue;
if (!masterKeyEnabled(mk)) continue;
if (!valid) return true;
}
return false;
};
export const upgradeMasterKey = async (masterKey: MasterKeyEntity, passwordChecks: PasswordChecks, passwords: Record<string, string>): Promise<string> => {
const passwordCheck = passwordChecks[masterKey.id];
if (!passwordCheck) {