empty password handling

This commit is contained in:
Akinwale Ariwodola 2019-09-06 14:40:38 +01:00
parent ad810d5c9e
commit 7a141c817e
4 changed files with 10 additions and 7 deletions

View file

@ -33,7 +33,7 @@ class FirstRunScreen extends React.PureComponent {
isEmailVerified: false, isEmailVerified: false,
skipAccountConfirmed: false, skipAccountConfirmed: false,
showBottomContainer: false, showBottomContainer: false,
walletPassword: null, walletPassword: '',
syncApplyStarted: false, syncApplyStarted: false,
}; };
@ -253,7 +253,7 @@ class FirstRunScreen extends React.PureComponent {
}; };
onWalletPasswordChanged = password => { onWalletPasswordChanged = password => {
this.setState({ walletPassword: password }); this.setState({ walletPassword: password !== null ? password : '' });
}; };
onWalletViewLayout = () => { onWalletViewLayout = () => {

View file

@ -166,14 +166,14 @@ class SplashScreen extends React.PureComponent {
// For now, automatically unlock the wallet if a password is set so that downloads work // 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 => { NativeModules.UtilityModule.getSecureValue(Constants.KEY_FIRST_RUN_PASSWORD).then(password => {
if (password && password.trim().length > 0) { if (password) {
this.setState({ this.setState({
message: 'Unlocking account', message: 'Unlocking account',
details: 'Decrypting wallet', details: 'Decrypting wallet',
}); });
// unlock the wallet and then finish the splash screen // unlock the wallet and then finish the splash screen
Lbry.account_unlock({ password }) Lbry.account_unlock({ password: password || '' })
.then(() => { .then(() => {
this.setState({ this.setState({
message: testingNetwork, message: testingNetwork,

View file

@ -5,7 +5,7 @@ import { BarPasswordStrengthDisplay } from 'react-native-password-strength-meter
import Button from 'component/button'; import Button from 'component/button';
import Link from 'component/link'; import Link from 'component/link';
import Colors from 'styles/colors'; 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 firstRunStyle from 'styles/firstRun';
import Icon from 'react-native-vector-icons/FontAwesome5'; import Icon from 'react-native-vector-icons/FontAwesome5';
import rewardStyle from 'styles/reward'; import rewardStyle from 'styles/reward';
@ -62,7 +62,10 @@ class SyncVerifyPage extends React.PureComponent {
} else { } else {
// password successfully verified // password successfully verified
if (NativeModules.UtilityModule) { 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(); setDefaultAccount();
setClientSetting(Constants.SETTING_DEVICE_WALLET_SYNCED, true); setClientSetting(Constants.SETTING_DEVICE_WALLET_SYNCED, true);

View file

@ -47,7 +47,7 @@ class WalletPage extends React.PureComponent {
const { deviceWalletSynced, getSync, user } = this.props; const { deviceWalletSynced, getSync, user } = this.props;
if (deviceWalletSynced && user && user.has_verified_email) { if (deviceWalletSynced && user && user.has_verified_email) {
NativeModules.UtilityModule.getSecureValue(Constants.KEY_FIRST_RUN_PASSWORD).then(walletPassword => { NativeModules.UtilityModule.getSecureValue(Constants.KEY_FIRST_RUN_PASSWORD).then(walletPassword => {
if (walletPassword && walletPassword.trim().length > 0) { if (walletPassword) {
getSync(walletPassword); getSync(walletPassword);
} }
}); });