handle account unlock failure (#594)

* display information to the user upon account_unlock failure
* remove trailing dots in messages
This commit is contained in:
Akinwale Ariwodola 2019-07-07 15:26:20 +01:00 committed by GitHub
parent 4186081fdc
commit 01534caf13
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 105 additions and 25 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

@ -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())