tweaks to the user email verification process #236
3 changed files with 68 additions and 38 deletions
|
@ -216,6 +216,10 @@ class AppWithNavigationState extends React.Component {
|
||||||
this.setState({ emailVerifyDone: true });
|
this.setState({ emailVerifyDone: true });
|
||||||
const message = emailVerifyErrorMessage ?
|
const message = emailVerifyErrorMessage ?
|
||||||
String(emailVerifyErrorMessage) : 'Your email address was successfully verified.';
|
String(emailVerifyErrorMessage) : 'Your email address was successfully verified.';
|
||||||
|
if (!emailVerifyErrorMessage) {
|
||||||
|
AsyncStorage.removeItem(Constants.KEY_FIRST_RUN_EMAIL);
|
||||||
|
}
|
||||||
|
AsyncStorage.removeItem(Constants.KEY_SHOULD_VERIFY_EMAIL);
|
||||||
dispatch(doNotify({ message, displayType: ['toast'] }));
|
dispatch(doNotify({ message, displayType: ['toast'] }));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
@ -1,16 +1,25 @@
|
||||||
import { connect } from 'react-redux';
|
import { connect } from 'react-redux';
|
||||||
import { doBalanceSubscribe, doNotify } from 'lbry-redux';
|
import { doBalanceSubscribe, doNotify } from 'lbry-redux';
|
||||||
import { doAuthenticate, doUserEmailVerify, doUserEmailVerifyFailure, selectUser } from 'lbryinc';
|
import {
|
||||||
|
doAuthenticate,
|
||||||
|
doUserEmailToVerify,
|
||||||
|
doUserEmailVerify,
|
||||||
|
doUserEmailVerifyFailure,
|
||||||
|
selectUser,
|
||||||
|
selectEmailToVerify
|
||||||
|
} from 'lbryinc';
|
||||||
import SplashScreen from './view';
|
import SplashScreen from './view';
|
||||||
|
|
||||||
const select = state => ({
|
const select = state => ({
|
||||||
user: selectUser(state),
|
user: selectUser(state),
|
||||||
|
emailToVerify: selectEmailToVerify(state)
|
||||||
});
|
});
|
||||||
|
|
||||||
const perform = dispatch => ({
|
const perform = dispatch => ({
|
||||||
authenticate: (appVersion, deviceId) => dispatch(doAuthenticate(appVersion, deviceId)),
|
authenticate: (appVersion, deviceId) => dispatch(doAuthenticate(appVersion, deviceId)),
|
||||||
balanceSubscribe: () => dispatch(doBalanceSubscribe()),
|
balanceSubscribe: () => dispatch(doBalanceSubscribe()),
|
||||||
notify: data => dispatch(doNotify(data)),
|
notify: data => dispatch(doNotify(data)),
|
||||||
|
setEmailToVerify: email => dispatch(doUserEmailToVerify(email)),
|
||||||
verifyUserEmail: (token, recaptcha) => dispatch(doUserEmailVerify(token, recaptcha)),
|
verifyUserEmail: (token, recaptcha) => dispatch(doUserEmailVerify(token, recaptcha)),
|
||||||
verifyUserEmailFailure: error => dispatch(doUserEmailVerifyFailure(error)),
|
verifyUserEmailFailure: error => dispatch(doUserEmailVerifyFailure(error)),
|
||||||
});
|
});
|
||||||
|
|
|
@ -57,10 +57,23 @@ class SplashScreen extends React.PureComponent {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
componentWillUpdate(nextProps) {
|
componentWillReceiveProps(nextProps) {
|
||||||
const { navigation, verifyUserEmail, verifyUserEmailFailure } = this.props;
|
const {
|
||||||
|
emailToVerify,
|
||||||
|
navigation,
|
||||||
|
setEmailToVerify,
|
||||||
|
verifyUserEmail,
|
||||||
|
verifyUserEmailFailure
|
||||||
|
} = this.props;
|
||||||
const { user } = nextProps;
|
const { user } = nextProps;
|
||||||
|
|
||||||
if (this.state.daemonReady && this.state.shouldAuthenticate && user && user.id) {
|
if (this.state.daemonReady && this.state.shouldAuthenticate && user && user.id) {
|
||||||
|
this.setState({ shouldAuthenticate: false }, () => {
|
||||||
|
AsyncStorage.getItem(Constants.KEY_FIRST_RUN_EMAIL).then(email => {
|
||||||
|
if (email) {
|
||||||
|
setEmailToVerify(email);
|
||||||
|
}
|
||||||
|
|
||||||
// user is authenticated, navigate to the main view
|
// user is authenticated, navigate to the main view
|
||||||
const resetAction = NavigationActions.reset({
|
const resetAction = NavigationActions.reset({
|
||||||
index: 0,
|
index: 0,
|
||||||
|
@ -98,6 +111,8 @@ class SplashScreen extends React.PureComponent {
|
||||||
navigation.navigate({ routeName: 'File', key: launchUrl, params: { uri: launchUrl } });
|
navigation.navigate({ routeName: 'File', key: launchUrl, params: { uri: launchUrl } });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -129,6 +144,7 @@ class SplashScreen extends React.PureComponent {
|
||||||
|
|
||||||
balanceSubscribe();
|
balanceSubscribe();
|
||||||
NativeModules.VersionInfo.getAppVersion().then(appVersion => {
|
NativeModules.VersionInfo.getAppVersion().then(appVersion => {
|
||||||
|
this.setState({ shouldAuthenticate: true });
|
||||||
if (NativeModules.UtilityModule) {
|
if (NativeModules.UtilityModule) {
|
||||||
// authenticate with the device ID if the method is available
|
// authenticate with the device ID if the method is available
|
||||||
NativeModules.UtilityModule.getDeviceId().then(deviceId => {
|
NativeModules.UtilityModule.getDeviceId().then(deviceId => {
|
||||||
|
@ -137,9 +153,9 @@ class SplashScreen extends React.PureComponent {
|
||||||
} else {
|
} else {
|
||||||
authenticate(appVersion);
|
authenticate(appVersion);
|
||||||
}
|
}
|
||||||
this.setState({ shouldAuthenticate: true });
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -177,6 +193,7 @@ class SplashScreen extends React.PureComponent {
|
||||||
details: 'Initializing LBRY service...'
|
details: 'Initializing LBRY service...'
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
this.updateStatus();
|
this.updateStatus();
|
||||||
}, 500);
|
}, 500);
|
||||||
|
|
Loading…
Reference in a new issue