do not call wallet_encrypt with blank password #60

Merged
akinwale merged 1 commit from blank-password-encrypt into master 2019-10-20 20:31:16 +02:00
2 changed files with 18 additions and 5 deletions

View file

@ -300,6 +300,12 @@ class FirstRunScreen extends React.PureComponent {
if (NativeModules.UtilityModule) { if (NativeModules.UtilityModule) {
const newPassword = this.state.walletPassword ? this.state.walletPassword : ''; const newPassword = this.state.walletPassword ? this.state.walletPassword : '';
NativeModules.UtilityModule.setSecureValue(Constants.KEY_WALLET_PASSWORD, newPassword); NativeModules.UtilityModule.setSecureValue(Constants.KEY_WALLET_PASSWORD, newPassword);
if (newPassword.trim().length === 0) {
// blank password. Do not encrypt
getSync(newPassword);
setClientSetting(Constants.SETTING_DEVICE_WALLET_SYNCED, true);
this.closeFinalPage();
} else {
Lbry.wallet_encrypt({ new_password: newPassword }).then(() => { Lbry.wallet_encrypt({ new_password: newPassword }).then(() => {
// fresh account, new password set // fresh account, new password set
getSync(newPassword); getSync(newPassword);
@ -307,6 +313,7 @@ class FirstRunScreen extends React.PureComponent {
this.closeFinalPage(); this.closeFinalPage();
}); });
} }
}
}; };
render() { render() {

View file

@ -37,11 +37,17 @@ class SyncVerifyPage extends React.PureComponent {
if (!hasSyncedWallet) { if (!hasSyncedWallet) {
// fresh account with no sync // fresh account with no sync
const newPassword = this.state.password ? this.state.password : ''; const newPassword = this.state.password ? this.state.password : '';
if (newPassword.trim().length === 0) {
getSync(newPassword);
setClientSetting(Constants.SETTING_DEVICE_WALLET_SYNCED, true);
navigation.goBack();
} else {
Lbry.wallet_encrypt({ new_password: newPassword }).then(() => { Lbry.wallet_encrypt({ new_password: newPassword }).then(() => {
getSync(newPassword); getSync(newPassword);
setClientSetting(Constants.SETTING_DEVICE_WALLET_SYNCED, true); setClientSetting(Constants.SETTING_DEVICE_WALLET_SYNCED, true);
navigation.goBack(); navigation.goBack();
}); });
}
} else { } else {
syncApply(syncHash, syncData, this.state.password ? this.state.password : ''); syncApply(syncHash, syncData, this.state.password ? this.state.password : '');
} }