handle account unlock failure #594

Merged
akinwale merged 4 commits from account-unlock-fail into master 2019-07-07 16:26:21 +02:00
3 changed files with 112 additions and 32 deletions

View file

@ -6,6 +6,7 @@ import { decode as atob } from 'base-64';
import { navigateToUri } from 'utils/helper';
import moment from 'moment';
import AsyncStorage from '@react-native-community/async-storage';
import Button from 'component/button';
import ProgressBar from 'component/progressBar';
import PropTypes from 'prop-types';
import Colors from 'styles/colors';
@ -14,15 +15,18 @@ import splashStyle from 'styles/splash';
const BLOCK_HEIGHT_INTERVAL = 1000 * 60 * 2.5; // every 2.5 minutes
const testingNetwork = 'Testing network';
const waitingForResolution = 'Waiting for name resolution';
class SplashScreen extends React.PureComponent {
static navigationOptions = {
title: 'Splash',
};
componentWillMount() {
this.setState({
state = {
accountUnlockFailed: false,
daemonReady: false,
details: 'Starting up...',
details: 'Starting up',
message: 'Connecting',
isRunning: false,
isLagging: false,
@ -31,8 +35,9 @@ class SplashScreen extends React.PureComponent {
headersDownloadProgress: 0,
shouldAuthenticate: false,
subscriptionsFetched: false,
});
};
componentWillMount() {
if (NativeModules.DaemonServiceControl) {
NativeModules.DaemonServiceControl.startService();
}
@ -143,6 +148,10 @@ class SplashScreen extends React.PureComponent {
});
};
handleAccountUnlockFailed() {
this.setState({ accountUnlockFailed: true });
}
_updateStatusCallback(status) {
const { fetchSubscriptions, getSync, setClientSetting } = this.props;
const startupStatus = status.startup_status;
@ -155,8 +164,6 @@ class SplashScreen extends React.PureComponent {
// to give us a better sense of when we are actually started
this.setState({
daemonReady: true,
message: 'Testing Network',
details: 'Waiting for name resolution',
isLagging: false,
isRunning: true,
});
@ -164,14 +171,29 @@ 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) {
this.setState({
message: 'Unlocking account',
details: 'Decrypting wallet',
});
// unlock the wallet and then finish the splash screen
Lbry.account_unlock({ password })
.then(() => this.finishSplashScreen())
.catch(() => this.finishSplashScreen());
return;
}
.then(() => {
this.setState({
message: testingNetwork,
details: waitingForResolution,
});
this.finishSplashScreen();
})
.catch(() => this.handleAccountUnlockFailed());
return;
} else {
this.setState({
message: testingNetwork,
details: waitingForResolution,
});
this.finishSplashScreen();
}
});
return;
@ -208,7 +230,7 @@ class SplashScreen extends React.PureComponent {
} else {
this.setState({
message: 'Network Loading',
details: 'Initializing LBRY service...',
details: 'Initializing LBRY service',
});
}
@ -253,8 +275,41 @@ class SplashScreen extends React.PureComponent {
});
}
handleContinueAnywayPressed = () => {
this.setState(
{
accountUnlockFailed: false,
message: testingNetwork,
details: waitingForResolution,
},
() => this.finishSplashScreen()
);
};
render() {
const { message, details, isLagging, isRunning } = this.state;
const { accountUnlockFailed, message, details, isLagging, isRunning } = this.state;
if (accountUnlockFailed) {
return (
<View style={splashStyle.container}>
<Text style={splashStyle.errorTitle}>Oops! Something went wrong.</Text>
<Text style={splashStyle.paragraph}>
Your wallet failed to unlock, which means you may not be able to play any videos or access your funds.
</Text>
<Text style={splashStyle.paragraph}>
You can try to fix this by tapping Stop on the LBRY service notification and starting the app again. If the
problem continues, you may have to reinstall the app and restore your account.
</Text>
<Button
style={splashStyle.continueButton}
theme={'light'}
text={'Continue anyway'}
onPress={this.handleContinueAnywayPressed}
/>
</View>
);
}
return (
<View style={splashStyle.container}>

View file

@ -14,6 +14,31 @@ const splashStyle = StyleSheet.create({
marginBottom: 48,
color: Colors.White,
},
errorTitle: {
fontFamily: 'Inter-UI-Regular',
fontSize: 28,
marginBottom: 24,
marginLeft: 24,
marginRight: 24,
color: Colors.White,
},
paragraph: {
fontFamily: 'Inter-UI-Regular',
fontSize: 16,
lineHeight: 24,
marginBottom: 20,
marginLeft: 24,
marginRight: 24,
color: Colors.White,
},
continueButton: {
fontSize: 16,
backgroundColor: Colors.White,
marginTop: 24,
marginLeft: 24,
marginRight: 24,
alignSelf: 'flex-end',
},
loading: {
marginBottom: 36,
},

View file

@ -6,13 +6,13 @@ import platform
import sys
from jnius import autoclass
from keyring.backend import KeyringBackend
from lbrynet import __version__ as lbrynet_version, build_type
from lbrynet.conf import Config
from lbrynet.extras.daemon.loggly_handler import get_loggly_handler
from lbrynet.extras.daemon.Components import DHT_COMPONENT, HASH_ANNOUNCER_COMPONENT, PEER_PROTOCOL_SERVER_COMPONENT
from lbrynet.extras.daemon.Daemon import Daemon
from lbrynet.extras.daemon.loggly_handler import get_loggly_handler
from lbrynet.utils import check_connection
from lbry import __version__ as lbrynet_version, build_type
from lbry.conf import Config
from lbry.extras.daemon.loggly_handler import get_loggly_handler
from lbry.extras.daemon.Components import DHT_COMPONENT, HASH_ANNOUNCER_COMPONENT, PEER_PROTOCOL_SERVER_COMPONENT
from lbry.extras.daemon.Daemon import Daemon
from lbry.extras.daemon.loggly_handler import get_loggly_handler
from lbry.utils import check_connection
log = logging.getLogger(__name__)
log.setLevel(logging.DEBUG)
@ -52,24 +52,24 @@ def configure_logging(conf):
conf.log_file_path, maxBytes=2097152, backupCount=5
)
file_handler.setFormatter(default_formatter)
logging.getLogger('lbrynet').addHandler(file_handler)
logging.getLogger('lbry').addHandler(file_handler)
logging.getLogger('torba').addHandler(file_handler)
handler = logging.StreamHandler()
handler.setFormatter(default_formatter)
log.addHandler(handler)
logging.getLogger('lbrynet').addHandler(handler)
logging.getLogger('lbry').addHandler(handler)
logging.getLogger('torba').addHandler(handler)
logging.getLogger('aioupnp').setLevel(logging.WARNING)
logging.getLogger('aiohttp').setLevel(logging.CRITICAL)
logging.getLogger('lbrynet').setLevel(logging.DEBUG if lbrynet_android_utils.isDebug() else logging.INFO)
logging.getLogger('lbry').setLevel(logging.DEBUG if lbrynet_android_utils.isDebug() else logging.INFO)
logging.getLogger('torba').setLevel(logging.INFO)
loggly_handler = get_loggly_handler()
loggly_handler.setLevel(logging.ERROR)
logging.getLogger('lbrynet').addHandler(loggly_handler)
logging.getLogger('lbry').addHandler(loggly_handler)
def start():
keyring.set_keyring(LbryAndroidKeyring())