Skip to content

A fully open source & end-to-end encrypted note taking alternative to Evernote.

correctly handle verify password before backup

ammarahm-edb2d607e8c2dc
diff --git a/apps/mobile/src/components/Dialog/index.js b/apps/mobile/src/components/Dialog/index.js
index 9c7ebf292..6242e8cdc 100644
--- a/apps/mobile/src/components/Dialog/index.js
+++ b/apps/mobile/src/components/Dialog/index.js
@@ -9,6 +9,7 @@ import {ph, pv} from '../../utils/SizeUtils';
import {sleep} from '../../utils/TimeUtils';
import Input from '../Input';
import Seperator from '../Seperator';
+import { Toast } from '../Toast';
import BaseDialog from './base-dialog';
import DialogButtons from './dialog-buttons';
import DialogHeader from './dialog-header';
@@ -47,7 +48,10 @@ export const Dialog = ({context = 'global'}) => {
const onPressPositive = async () => {
if (dialogInfo.positivePress) {
inputRef.current?.blur();
- await dialogInfo.positivePress(inputValue || dialogInfo.defaultValue);
+ let result = await dialogInfo.positivePress(inputValue || dialogInfo.defaultValue);
+ if (result === false) {
+ return;
+ }
}
hide();
};
@@ -99,7 +103,7 @@ export const Dialog = ({context = 'global'}) => {
paragraph={dialogInfo.paragraph}
paragraphColor={dialogInfo.paragraphColor}
/>
- <Seperator />
+ <Seperator half />
{dialogInfo.input && (
<Input
@@ -108,6 +112,7 @@ export const Dialog = ({context = 'global'}) => {
onChangeText={value => {
setInputValue(value);
}}
+ secureTextEntry={dialogInfo.secureTextEntry}
defaultValue={dialogInfo.defaultValue}
onSubmit={onPressPositive}
returnKeyLabel="Done"
@@ -124,6 +129,7 @@ export const Dialog = ({context = 'global'}) => {
positiveType={dialogInfo.positiveType}
/>
</View>
+ <Toast context="local"/>
</BaseDialog>
)
);
diff --git a/apps/mobile/src/views/Settings/index.js b/apps/mobile/src/views/Settings/index.js
index d4856f3fe..af5073ded 100644
--- a/apps/mobile/src/views/Settings/index.js
+++ b/apps/mobile/src/views/Settings/index.js
@@ -1727,24 +1727,31 @@ export const SettingsBackupAndRestore = ({isSheet}) => {
inputPlaceholder: 'Enter account password',
paragraph: 'Please enter your account password to backup data',
positiveText: 'Verify',
+ secureTextEntry:true,
positivePress: async value => {
try {
- let verified = db.user.verifyPassword(value);
+ let verified = await db.user.verifyPassword(value);
if (verified) {
- await Backup.run();
+ sleep(300).then(async () => {
+ await Backup.run();
+ })
} else {
ToastEvent.show({
heading: 'Incorrect password',
message: 'The account password you entered is incorrect',
- type: 'error'
+ type: 'error',
+ context: 'local'
});
+ return false;
}
} catch (e) {
ToastEvent.show({
heading: 'Failed to backup data',
message: e.message,
- type: 'error'
+ type: 'error',
+ context: 'local'
});
+ return false;
}
}
});