1
0
mirror of https://github.com/laurent22/joplin.git synced 2025-01-23 18:53:36 +02:00

Mobile: confirm encryption password (#1939)

* mobile: confirm encryption password

* pr feedback: translatable strings + style refactor

also added placeholder text

* s/did/do
This commit is contained in:
Nathan Leiby 2019-10-08 15:04:25 -07:00 committed by Helmut K. C. Tessarek
parent f2c82b05d9
commit fdcf27fc65

View File

@ -23,6 +23,7 @@ class EncryptionConfigScreenComponent extends BaseScreenComponent {
this.state = {
passwordPromptShow: false,
passwordPromptAnswer: '',
passwordPromptConfirmAnswer: '',
};
shared.constructor(this);
@ -82,6 +83,12 @@ class EncryptionConfigScreenComponent extends BaseScreenComponent {
fontSize: theme.fontSize,
color: theme.color,
},
normalTextInput: {
margin: 10,
color: theme.color,
borderWidth: 1,
borderColor: theme.dividerColor,
},
container: {
flex: 1,
padding: theme.margin,
@ -131,6 +138,9 @@ class EncryptionConfigScreenComponent extends BaseScreenComponent {
try {
const password = this.state.passwordPromptAnswer;
if (!password) throw new Error(_('Password cannot be empty'));
const password2 = this.state.passwordPromptConfirmAnswer;
if (!password2) throw new Error(_('Confirm password cannot be empty'));
if (password !== password2) throw new Error(_('Passwords do not match!'));
await EncryptionService.instance().generateMasterKeyAndEnableEncryption(password);
this.setState({ passwordPromptShow: false });
} catch (error) {
@ -140,16 +150,30 @@ class EncryptionConfigScreenComponent extends BaseScreenComponent {
return (
<View style={{ flex: 1, borderColor: theme.dividerColor, borderWidth: 1, padding: 10, marginTop: 10, marginBottom: 10 }}>
<Text style={{ fontSize: theme.fontSize, color: theme.color }}>{_('Enabling encryption means *all* your notes and attachments are going to be re-synchronised and sent encrypted to the sync target. Do not lose the password as, for security purposes, this will be the *only* way to decrypt the data! To enable encryption, please enter your password below.')}</Text>
<Text style={{ fontSize: theme.fontSize, color: theme.color, marginBottom: 10 }}>{_('Enabling encryption means *all* your notes and attachments are going to be re-synchronised and sent encrypted to the sync target. Do not lose the password as, for security purposes, this will be the *only* way to decrypt the data! To enable encryption, please enter your password below.')}</Text>
<Text style={this.styles().normalText}>{_('Password:')}</Text>
<TextInput
placeholder={_('Password')}
selectionColor={theme.textSelectionColor}
style={{ margin: 10, color: theme.color, borderWidth: 1, borderColor: theme.dividerColor }}
style={this.styles().normalTextInput}
secureTextEntry={true}
value={this.state.passwordPromptAnswer}
onChangeText={text => {
this.setState({ passwordPromptAnswer: text });
}}
></TextInput>
<Text style={this.styles().normalText}>{_('Confirm password:')}</Text>
<TextInput
placeholder={_('Confirm password')}
selectionColor={theme.textSelectionColor}
style={this.styles().normalTextInput}
secureTextEntry={true}
value={this.state.passwordPromptConfirmAnswer}
onChangeText={text => {
this.setState({ passwordPromptConfirmAnswer: text });
}}
></TextInput>
<View style={{ flexDirection: 'row' }}>
<View style={{ flex: 1, marginRight: 10 }}>
<Button
@ -203,6 +227,7 @@ class EncryptionConfigScreenComponent extends BaseScreenComponent {
this.setState({
passwordPromptShow: true,
passwordPromptAnswer: '',
passwordPromptConfirmAnswer: '',
});
return;
}