From d41574235fe3459d7df73dd92c47c309db81f85f Mon Sep 17 00:00:00 2001 From: Julia Friesel Date: Fri, 14 Sep 2018 13:43:45 +0200 Subject: [PATCH] Add forgot password flow --- components/labels.js | 9 +++++++- components/password-prompt.js | 39 ++++++++++++++++++++++++++++------- styles/index.js | 4 ++++ 3 files changed, 43 insertions(+), 9 deletions(-) diff --git a/components/labels.js b/components/labels.js index 1c90f88..d4b5876 100644 --- a/components/labels.js +++ b/components/labels.js @@ -107,5 +107,12 @@ export const bleedingPrediction = { export const passwordPrompt = { title: 'Unlock app', - enterPassword: 'Enter password here' + enterPassword: 'Enter password here', + deleteDatabaseExplainer: "If you've forgotten your password, unfortunately, there is nothing we can do to recover your data, because it is encrypted with the password only you know. You can, however, delete all your encrypted data and start fresh. Once all data has been erased, you can set a new password in the settings, if you like.", + forgotPassword: 'Forgot your password?', + deleteDatabaseTitle: 'Forgot your password?', + deleteData: 'Yes, delete all my data', + areYouSureTitle: 'Are you sure?', + areYouSure: 'Are you absolutely sure you want to permanently delete all your data?', + reallyDeleteData: 'Yes, I am sure' } \ No newline at end of file diff --git a/components/password-prompt.js b/components/password-prompt.js index 7351689..3c972eb 100644 --- a/components/password-prompt.js +++ b/components/password-prompt.js @@ -4,7 +4,7 @@ import nodejs from 'nodejs-mobile-react-native' import { AppText } from './app-text' import { hasEncryptionObservable } from '../local-storage' import styles from '../styles' -import { passwordPrompt, shared } from './labels' +import { passwordPrompt as labels, shared } from './labels' import { requestHash, deleteDbAndOpenNew, openDb } from '../db' export default class PasswordPrompt extends Component { @@ -66,7 +66,7 @@ export default class PasswordPrompt extends Component { onChangeText={val => this.setState({ password: val })} style={styles.passwordPromptField} secureTextEntry={true} - placeholder={passwordPrompt.enterPassword} + placeholder={labels.enterPassword} /> - {passwordPrompt.title} + {labels.title} { - await deleteDbAndOpenNew() - this.setState({ showApp: true }) + Alert.alert( + labels.deleteDatabaseTitle, + labels.deleteDatabaseExplainer, + [{ + text: shared.cancel, + style: 'cancel' + }, { + text: labels.deleteData, + onPress: () => { + Alert.alert( + labels.areYouSureTitle, + labels.areYouSure, + [{ + text: shared.cancel, + style: 'cancel' + }, { + text: labels.reallyDeleteData, + onPress: async () => { + await deleteDbAndOpenNew() + this.props.showApp() + } + }] + ) + } + }] + ) }} > - - {'Delete old db and make unencrypted new'} + + {labels.forgotPassword} diff --git a/styles/index.js b/styles/index.js index 82c6e71..ee63b83 100644 --- a/styles/index.js +++ b/styles/index.js @@ -282,6 +282,10 @@ export default StyleSheet.create({ color: fontOnPrimaryColor, fontSize: 20 }, + passwordPromptForgotPasswordText: { + marginTop: 20, + color: 'grey' + } }) export const iconStyles = {