Desktop: Improved master password state handling in Encryption screen

This commit is contained in:
Laurent Cozic committed 2021-10-17 19:10:37 +01:00
1 parent 8d09ed3bac
commit 7d62df8906
3 files changed
+15 -4

No files matched your search

@@ -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) {