mirror of
https://github.com/laurent22/joplin.git
synced 2024-12-24 10:27:10 +02:00
Mobile: Fixes #5585: Fixed logic of setting master password in Encryption screen
This commit is contained in:
parent
a5560a6652
commit
1406d97b3e
@ -106,7 +106,7 @@ const EncryptionConfigScreen = (props: Props) => {
|
||||
<View style={{ flex: 1, flexDirection: 'row', alignItems: 'center' }}>
|
||||
<TextInput selectionColor={theme.textSelectionColor} keyboardAppearance={theme.keyboardAppearance} secureTextEntry={true} value={password} onChangeText={(text: string) => onInputPasswordChange(mk, text)} style={inputStyle}></TextInput>
|
||||
<Text style={{ fontSize: theme.fontSize, marginRight: 10, color: theme.color }}>{passwordOk}</Text>
|
||||
<Button title={_('Save')} onPress={() => onSavePasswordClick(mk, props.passwords)}></Button>
|
||||
<Button title={_('Save')} onPress={() => onSavePasswordClick(mk, inputPasswords)}></Button>
|
||||
</View>
|
||||
);
|
||||
}
|
||||
|
@ -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());
|
||||
|
@ -96,6 +96,13 @@ export const onSavePasswordClick = (mk: MasterKeyEntity, passwords: Record<strin
|
||||
} else {
|
||||
Setting.setObjectValue('encryption.passwordCache', mk.id, password);
|
||||
}
|
||||
|
||||
// When setting a master key password, if the master password is not set, we
|
||||
// assume that this password is the master password. If it turns out it's
|
||||
// not, it's always possible to change it in the UI.
|
||||
if (password && !Setting.value('encryption.masterPassword')) {
|
||||
Setting.setValue('encryption.masterPassword', password);
|
||||
}
|
||||
};
|
||||
|
||||
export const onMasterPasswordSave = (masterPasswordInput: string) => {
|
||||
@ -141,6 +148,11 @@ export const useInputPasswords = (propsPasswords: Record<string, string>) => {
|
||||
|
||||
export const usePasswordChecker = (masterKeys: MasterKeyEntity[], activeMasterKeyId: string, masterPassword: string, passwords: Record<string, string>) => {
|
||||
const [passwordChecks, setPasswordChecks] = useState<PasswordChecks>({});
|
||||
|
||||
// "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<PasswordChecks>({});
|
||||
const [masterPasswordStatus, setMasterPasswordStatus] = useState<MasterPasswordStatus>(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;
|
||||
});
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user