From 1406d97b3e84e89bb22e08e14f0b1ca2aa717419 Mon Sep 17 00:00:00 2001 From: Laurent Cozic Date: Sun, 17 Oct 2021 17:20:59 +0100 Subject: [PATCH] Mobile: Fixes #5585: Fixed logic of setting master password in Encryption screen --- .../components/screens/encryption-config.tsx | 2 +- packages/app-mobile/root.tsx | 6 +++++- .../lib/components/EncryptionConfigScreen/utils.ts | 13 ++++++++++++- 3 files changed, 18 insertions(+), 3 deletions(-) diff --git a/packages/app-mobile/components/screens/encryption-config.tsx b/packages/app-mobile/components/screens/encryption-config.tsx index ea5973d4e0e..6e885535bee 100644 --- a/packages/app-mobile/components/screens/encryption-config.tsx +++ b/packages/app-mobile/components/screens/encryption-config.tsx @@ -106,7 +106,7 @@ const EncryptionConfigScreen = (props: Props) => { onInputPasswordChange(mk, text)} style={inputStyle}> {passwordOk} - + ); } diff --git a/packages/app-mobile/root.tsx b/packages/app-mobile/root.tsx index 887a57bdc3e..e29b45b4908 100644 --- a/packages/app-mobile/root.tsx +++ b/packages/app-mobile/root.tsx @@ -476,7 +476,7 @@ async function initialize(dispatch: Function) { if (Setting.value('env') == 'prod') { await db.open({ name: 'joplin.sqlite' }); } else { - await db.open({ name: 'joplin-104.sqlite' }); + await db.open({ name: 'joplin-107.sqlite' }); // await db.clearForTesting(); } @@ -492,6 +492,10 @@ async function initialize(dispatch: Function) { // Setting.setValue('sync.10.userContentPath', 'https://joplinusercontent.com'); Setting.setValue('sync.10.path', 'http://api.joplincloud.local:22300'); Setting.setValue('sync.10.userContentPath', 'http://joplinusercontent.local:22300'); + + Setting.setValue('sync.target', 10); + Setting.setValue('sync.10.username', 'user1@example.com'); + Setting.setValue('sync.10.password', 'hunter1hunter2hunter3'); } if (!Setting.value('clientId')) Setting.setValue('clientId', uuid.create()); diff --git a/packages/lib/components/EncryptionConfigScreen/utils.ts b/packages/lib/components/EncryptionConfigScreen/utils.ts index 1a3ce0bf5a6..bede33a86bc 100644 --- a/packages/lib/components/EncryptionConfigScreen/utils.ts +++ b/packages/lib/components/EncryptionConfigScreen/utils.ts @@ -96,6 +96,13 @@ export const onSavePasswordClick = (mk: MasterKeyEntity, passwords: Record { @@ -141,6 +148,11 @@ export const useInputPasswords = (propsPasswords: Record) => { export const usePasswordChecker = (masterKeys: MasterKeyEntity[], activeMasterKeyId: string, masterPassword: string, passwords: Record) => { const [passwordChecks, setPasswordChecks] = useState({}); + + // "masterPasswordKeys" are the master key that can be decrypted with the + // master password. It should be all of them normally, but in previous + // versions it was possible to have different passwords for different keys, + // so we need this for backward compatibility. const [masterPasswordKeys, setMasterPasswordKeys] = useState({}); const [masterPasswordStatus, setMasterPasswordStatus] = useState(MasterPasswordStatus.Unknown); @@ -167,7 +179,6 @@ export const usePasswordChecker = (masterKeys: MasterKeyEntity[], activeMasterKe setMasterPasswordKeys(masterPasswordKeys => { if (JSON.stringify(newMasterPasswordKeys) === JSON.stringify(masterPasswordKeys)) return masterPasswordKeys; - console.info('====', JSON.stringify(newMasterPasswordKeys), JSON.stringify(masterPasswordKeys)); return newMasterPasswordKeys; });