fix: blank password take 2

This commit is contained in:
Thomas Zarebczan 2019-10-21 20:12:43 -04:00 committed by Sean Yesmunt
parent f06aaef256
commit f5faf6f49b
3 changed files with 23 additions and 18 deletions

View file

@ -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)),
});

View file

@ -14,7 +14,7 @@ const FORTY_FIVE_SECONDS = 45 * 1000;
type Props = {
checkDaemonVersion: () => Promise<any>,
notifyUnlockWallet: () => Promise<any>,
notifyUnlockWallet: (?boolean) => Promise<any>,
daemonVersionMatched: boolean,
onReadyToLaunch: () => void,
authenticate: () => void,
@ -102,10 +102,14 @@ export default class SplashScreen extends React.PureComponent<Props, State> {
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) {

View file

@ -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<Props, State> {
};
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;