diff --git a/package.json b/package.json index 95643e578..b1a9ac9fb 100644 --- a/package.json +++ b/package.json @@ -52,7 +52,7 @@ "hast-util-sanitize": "^1.1.2", "keytar": "^4.2.1", "lbry-redux": "lbryio/lbry-redux#820b6eeadf9e58c1e5027fd4d92808ba817b410e", - "lbryinc": "lbryio/lbryinc#68c8ce6b7608dabc9180fff9b4841d10e1c62284", + "lbryinc": "lbryio/lbryinc#cee70d482cf352f2e66215fa109f4178406228ca", "localforage": "^1.7.1", "mammoth": "^1.4.6", "mime": "^2.3.1", diff --git a/src/renderer/component/userEmailVerify/index.js b/src/renderer/component/userEmailVerify/index.js index 6ac91cd13..d7953d481 100644 --- a/src/renderer/component/userEmailVerify/index.js +++ b/src/renderer/component/userEmailVerify/index.js @@ -1,24 +1,22 @@ import { connect } from 'react-redux'; import { - selectEmailVerifyIsPending, selectEmailToVerify, - selectEmailVerifyErrorMessage, - doUserEmailVerify, - doUserEmailVerifyFailure, doUserResendVerificationEmail, + doUserFetch, + selectUser, } from 'lbryinc'; +import { doNavigate } from 'redux/actions/navigation'; import UserEmailVerify from './view'; const select = state => ({ - isPending: selectEmailVerifyIsPending(state), email: selectEmailToVerify(state), - errorMessage: selectEmailVerifyErrorMessage(state), + user: selectUser(state), }); const perform = dispatch => ({ - verifyUserEmail: (code, recaptcha) => dispatch(doUserEmailVerify(code, recaptcha)), - verifyUserEmailFailure: error => dispatch(doUserEmailVerifyFailure(error)), resendVerificationEmail: email => dispatch(doUserResendVerificationEmail(email)), + doCheckEmailVerified: () => dispatch(doUserFetch(true)), + navigate: path => dispatch(doNavigate(path)), }); export default connect( diff --git a/src/renderer/component/userEmailVerify/view.jsx b/src/renderer/component/userEmailVerify/view.jsx index b9eed09ec..03c5d8d26 100644 --- a/src/renderer/component/userEmailVerify/view.jsx +++ b/src/renderer/component/userEmailVerify/view.jsx @@ -1,48 +1,37 @@ // @flow import * as React from 'react'; import Button from 'component/button'; -import { Form, FormField, FormRow, Submit } from 'component/common/form'; type Props = { cancelButton: React.Node, - errorMessage: ?string, email: string, - isPending: boolean, - onModal?: boolean, - verifyUserEmail: (string, string) => void, - verifyUserEmailFailure: string => void, resendVerificationEmail: string => void, + doCheckEmailVerified: () => void, + user: { + has_verified_email: boolean, + }, }; -type State = { - code: string, -}; - -class UserEmailVerify extends React.PureComponent { +class UserEmailVerify extends React.PureComponent { constructor(props: Props) { super(props); - - this.state = { - code: '', - }; - - (this: any).handleSubmit = this.handleSubmit.bind(this); + this.emailVerifyCheckInterval = null; (this: any).handleResendVerificationEmail = this.handleResendVerificationEmail.bind(this); } - handleCodeChanged(event: SyntheticInputEvent<*>) { - this.setState({ - code: String(event.target.value).trim(), - }); + componentDidMount() { + this.emailVerifyCheckInterval = setInterval(() => this.checkIfVerified(), 5000); } - handleSubmit() { - const { code } = this.state; - try { - const verification = JSON.parse(atob(code)); - this.props.verifyUserEmail(verification.token, verification.recaptcha); - } catch (error) { - this.props.verifyUserEmailFailure('Invalid Verification Token'); + componentDidUpdate() { + if (this.emailVerifyCheckInterval && this.props.user.has_verified_email) { + clearInterval(this.emailVerifyCheckInterval); + } + } + + componentWillUnmount() { + if (this.emailVerifyCheckInterval) { + clearInterval(this.emailVerifyCheckInterval); } } @@ -50,55 +39,38 @@ class UserEmailVerify extends React.PureComponent { this.props.resendVerificationEmail(this.props.email); } + checkIfVerified() { + const { doCheckEmailVerified } = this.props; + doCheckEmailVerified(); + } + + emailVerifyCheckInterval: ?IntervalID; + render() { - const { cancelButton, errorMessage, email, isPending, onModal } = this.props; + const { cancelButton, email } = this.props; return ( - -

Please enter the verification code emailed to {email}.

+
+

+ {__('An email was sent to')} {email}.{' '} + {__('Follow the link and you will be good to go. This will update automatically.')} +

-
- - this.handleCodeChanged(event)} - /> - +
+
-
- - {cancelButton} - {!onModal && ( -
- -

- {__('Email')}

- )} - -
+

+ {__('Email')}