Merge branch '242-password-not-working' into 'master'

Resolve "password not working"

Closes #242

See merge request bloodyhealth/drip!102
This commit is contained in:
Julia Friesel
2018-11-04 09:57:45 +00:00
3 changed files with 36 additions and 27 deletions
+4 -7
View File
@@ -24,22 +24,19 @@ export default class PasswordPrompt extends Component {
}
async tryToOpenDb() {
try {
await openDb({ persistConnection: true })
} catch (err) {
const connected = await openDb()
if (!connected) {
this.setState({ showPasswordPrompt: true })
await saveEncryptionFlag(true)
return
}
await saveEncryptionFlag(false)
this.props.showApp()
}
passHashToDb = async hash => {
try {
await openDb({ hash, persistConnection: true })
} catch (err) {
const connected = await openDb(hash)
if (!connected) {
Alert.alert(
shared.incorrectPassword,
shared.incorrectPasswordMessage,
@@ -3,21 +3,18 @@ import { openDb } from '../../../db'
import { shared } from '../../labels'
export default async function checkPassword({hash, onCancel, onTryAgain }) {
try {
await openDb({ hash, persistConnection: false })
return true
} catch (err) {
Alert.alert(
shared.incorrectPassword,
shared.incorrectPasswordMessage,
[{
text: shared.cancel,
onPress: onCancel
}, {
text: shared.tryAgain,
onPress: onTryAgain
}]
)
return false
}
const connected = await openDb(hash)
if (connected) return true
Alert.alert(
shared.incorrectPassword,
shared.incorrectPasswordMessage,
[{
text: shared.cancel,
onPress: onCancel
}, {
text: shared.tryAgain,
onPress: onTryAgain
}]
)
return false
}