From 7a141c817e0d64fb6e7b4b7cf1b620a89fe37345 Mon Sep 17 00:00:00 2001 From: Akinwale Ariwodola Date: Fri, 6 Sep 2019 14:40:38 +0100 Subject: [PATCH] empty password handling --- src/page/firstRun/view.js | 4 ++-- src/page/splash/view.js | 4 ++-- src/page/verification/internal/sync-verify-page.js | 7 +++++-- src/page/wallet/view.js | 2 +- 4 files changed, 10 insertions(+), 7 deletions(-) diff --git a/src/page/firstRun/view.js b/src/page/firstRun/view.js index 32756ca..b7fb517 100644 --- a/src/page/firstRun/view.js +++ b/src/page/firstRun/view.js @@ -33,7 +33,7 @@ class FirstRunScreen extends React.PureComponent { isEmailVerified: false, skipAccountConfirmed: false, showBottomContainer: false, - walletPassword: null, + walletPassword: '', syncApplyStarted: false, }; @@ -253,7 +253,7 @@ class FirstRunScreen extends React.PureComponent { }; onWalletPasswordChanged = password => { - this.setState({ walletPassword: password }); + this.setState({ walletPassword: password !== null ? password : '' }); }; onWalletViewLayout = () => { diff --git a/src/page/splash/view.js b/src/page/splash/view.js index 59e5d08..32bb2bc 100644 --- a/src/page/splash/view.js +++ b/src/page/splash/view.js @@ -166,14 +166,14 @@ class SplashScreen extends React.PureComponent { // For now, automatically unlock the wallet if a password is set so that downloads work NativeModules.UtilityModule.getSecureValue(Constants.KEY_FIRST_RUN_PASSWORD).then(password => { - if (password && password.trim().length > 0) { + if (password) { this.setState({ message: 'Unlocking account', details: 'Decrypting wallet', }); // unlock the wallet and then finish the splash screen - Lbry.account_unlock({ password }) + Lbry.account_unlock({ password: password || '' }) .then(() => { this.setState({ message: testingNetwork, diff --git a/src/page/verification/internal/sync-verify-page.js b/src/page/verification/internal/sync-verify-page.js index c53653b..f734a53 100644 --- a/src/page/verification/internal/sync-verify-page.js +++ b/src/page/verification/internal/sync-verify-page.js @@ -5,7 +5,7 @@ import { BarPasswordStrengthDisplay } from 'react-native-password-strength-meter import Button from 'component/button'; import Link from 'component/link'; import Colors from 'styles/colors'; -import Constants from 'constants'; +import Constants from 'constants'; // eslint-disable-line node/no-deprecated-api import firstRunStyle from 'styles/firstRun'; import Icon from 'react-native-vector-icons/FontAwesome5'; import rewardStyle from 'styles/reward'; @@ -62,7 +62,10 @@ class SyncVerifyPage extends React.PureComponent { } else { // password successfully verified if (NativeModules.UtilityModule) { - NativeModules.UtilityModule.setSecureValue(Constants.KEY_FIRST_RUN_PASSWORD, this.state.password); + NativeModules.UtilityModule.setSecureValue( + Constants.KEY_FIRST_RUN_PASSWORD, + this.state.password ? this.state.password : '' + ); } setDefaultAccount(); setClientSetting(Constants.SETTING_DEVICE_WALLET_SYNCED, true); diff --git a/src/page/wallet/view.js b/src/page/wallet/view.js index 20d40c1..df6c5f5 100644 --- a/src/page/wallet/view.js +++ b/src/page/wallet/view.js @@ -47,7 +47,7 @@ class WalletPage extends React.PureComponent { const { deviceWalletSynced, getSync, user } = this.props; if (deviceWalletSynced && user && user.has_verified_email) { NativeModules.UtilityModule.getSecureValue(Constants.KEY_FIRST_RUN_PASSWORD).then(walletPassword => { - if (walletPassword && walletPassword.trim().length > 0) { + if (walletPassword) { getSync(walletPassword); } });