From f5faf6f49b8762f62979c1d6b778c49617a6ae55 Mon Sep 17 00:00:00 2001 From: Thomas Zarebczan Date: Mon, 21 Oct 2019 20:12:43 -0400 Subject: [PATCH] fix: blank password take 2 --- src/ui/component/splash/index.js | 6 ++++-- src/ui/component/splash/view.jsx | 14 +++++++++----- src/ui/modal/modalWalletUnlock/view.jsx | 21 ++++++++++----------- 3 files changed, 23 insertions(+), 18 deletions(-) diff --git a/src/ui/component/splash/index.js b/src/ui/component/splash/index.js index 29b7701f6..13d22772f 100644 --- a/src/ui/component/splash/index.js +++ b/src/ui/component/splash/index.js @@ -1,6 +1,7 @@ +import * as MODALS from 'constants/modal_types'; import { connect } from 'react-redux'; import { selectDaemonVersionMatched, selectModal } from 'redux/selectors/app'; -import { doCheckDaemonVersion, doNotifyUnlockWallet, doHideModal } from 'redux/actions/app'; +import { doCheckDaemonVersion, doOpenModal, doHideModal } from 'redux/actions/app'; import { doSetClientSetting } from 'redux/actions/settings'; import * as settings from 'constants/settings'; import SplashScreen from './view'; @@ -15,7 +16,8 @@ const select = state => ({ const perform = dispatch => ({ checkDaemonVersion: () => dispatch(doCheckDaemonVersion()), - notifyUnlockWallet: () => dispatch(doNotifyUnlockWallet()), + notifyUnlockWallet: shouldTryWithBlankPassword => + dispatch(doOpenModal(MODALS.WALLET_UNLOCK, { shouldTryWithBlankPassword })), hideModal: () => dispatch(doHideModal()), setClientSetting: (key, value) => dispatch(doSetClientSetting(key, value)), }); diff --git a/src/ui/component/splash/view.jsx b/src/ui/component/splash/view.jsx index bbbf28725..3ac1893b0 100644 --- a/src/ui/component/splash/view.jsx +++ b/src/ui/component/splash/view.jsx @@ -14,7 +14,7 @@ const FORTY_FIVE_SECONDS = 45 * 1000; type Props = { checkDaemonVersion: () => Promise, - notifyUnlockWallet: () => Promise, + notifyUnlockWallet: (?boolean) => Promise, daemonVersionMatched: boolean, onReadyToLaunch: () => void, authenticate: () => void, @@ -102,10 +102,14 @@ export default class SplashScreen extends React.PureComponent { Lbry.status().then(status => { if (status.is_running) { Lbry.wallet_status().then(walletStatus => { - // Fix wallet bug and reset encryption status - if (walletStatus.is_encrypted && walletStatus.is_locked === false) { - this.setState({ launchedModal: true }, () => notifyUnlockWallet()); - this.updateStatusCallback(status, true); + // Fix blank password bug related to synced Android users and reset encryption status + // Remove this on 12/21/2019 to make sure we don't accidentilly decrypt any wallets + // This could happen if SDK is already running and app is started. + // This may be patched in a future SDK to support lbry.tv + // https://github.com/lbryio/lbry-sdk/issues/2576 + if (walletStatus.is_encrypted && walletStatus.is_locked === false && launchedModal === false) { + this.setState({ launchedModal: true }, () => notifyUnlockWallet(true)); + this.updateStatusCallback(status); } else if (walletStatus.is_locked) { // Clear the error timeout, it might sit on this step for a while until someone enters their password if (this.timeout) { diff --git a/src/ui/modal/modalWalletUnlock/view.jsx b/src/ui/modal/modalWalletUnlock/view.jsx index 7dc9f9837..bce55761b 100644 --- a/src/ui/modal/modalWalletUnlock/view.jsx +++ b/src/ui/modal/modalWalletUnlock/view.jsx @@ -10,6 +10,7 @@ type Props = { closeModal: () => void, unlockWallet: (?string) => void, walletUnlockSucceded: boolean, + shouldTryWithBlankPassword: boolean, }; type State = { @@ -24,18 +25,16 @@ class ModalWalletUnlock extends React.PureComponent { }; componentDidMount() { - const { unlockWallet } = this.props; + const { unlockWallet, shouldTryWithBlankPassword } = this.props; - getSavedPassword() - .then(p => { - if (p !== null) { - this.setState({ password: p, rememberPassword: true }); - unlockWallet(p); - } else { - unlockWallet(''); - } - }) - .catch(); + getSavedPassword().then(p => { + if (p !== null) { + this.setState({ password: p, rememberPassword: true }); + unlockWallet(p); + } else if (shouldTryWithBlankPassword) { + unlockWallet(''); + } + }); } componentDidUpdate() { const { props } = this;