From 8c343b16e3d381b7f056f6a7f2fba02d136f268b Mon Sep 17 00:00:00 2001 From: Amit Nandan P Date: Wed, 6 Jun 2018 20:47:49 -0500 Subject: [PATCH 1/5] #1492 Adding support to resend verification email --- .../component/userEmailVerify/index.js | 8 +++-- .../component/userEmailVerify/view.jsx | 13 +++++++- src/renderer/constants/action_types.js | 1 + src/renderer/redux/actions/user.js | 32 +++++++++++++++++++ 4 files changed, 51 insertions(+), 3 deletions(-) diff --git a/src/renderer/component/userEmailVerify/index.js b/src/renderer/component/userEmailVerify/index.js index f8c854ca1..886a0318a 100644 --- a/src/renderer/component/userEmailVerify/index.js +++ b/src/renderer/component/userEmailVerify/index.js @@ -1,6 +1,9 @@ -import React from 'react'; import { connect } from 'react-redux'; -import { doUserEmailVerify, doUserEmailVerifyFailure } from 'redux/actions/user'; +import { + doUserEmailVerify, + doUserEmailVerifyFailure, + doUserResendVerificationEmail, +} from 'redux/actions/user'; import { selectEmailVerifyIsPending, selectEmailToVerify, @@ -17,6 +20,7 @@ const select = state => ({ const perform = dispatch => ({ verifyUserEmail: (code, recaptcha) => dispatch(doUserEmailVerify(code, recaptcha)), verifyUserEmailFailure: error => dispatch(doUserEmailVerifyFailure(error)), + resendVerificationEmail: email => dispatch(doUserResendVerificationEmail(email)), }); export default connect(select, perform)(UserEmailVerify); diff --git a/src/renderer/component/userEmailVerify/view.jsx b/src/renderer/component/userEmailVerify/view.jsx index b5f634280..408b2d879 100644 --- a/src/renderer/component/userEmailVerify/view.jsx +++ b/src/renderer/component/userEmailVerify/view.jsx @@ -1,5 +1,5 @@ // @flow -import React from 'react'; +import * as React from 'react'; import Button from 'component/button'; import { Form, FormField, FormRow, Submit } from 'component/common/form'; @@ -10,6 +10,7 @@ type Props = { isPending: boolean, verifyUserEmail: (string, string) => void, verifyUserEmailFailure: string => void, + resendVerificationEmail: string => void, }; type State = { @@ -25,6 +26,7 @@ class UserEmailVerify extends React.PureComponent { }; (this: any).handleSubmit = this.handleSubmit.bind(this); + (this: any).handleResendVerification = this.handleResendVerification.bind(this); } handleCodeChanged(event: SyntheticInputEvent<*>) { @@ -43,6 +45,10 @@ class UserEmailVerify extends React.PureComponent { } } + handleResendVerification() { + this.props.resendVerificationEmail(this.props.email); + } + render() { const { cancelButton, errorMessage, email, isPending } = this.props; @@ -71,6 +77,11 @@ class UserEmailVerify extends React.PureComponent {
{cancelButton} +
); diff --git a/src/renderer/constants/action_types.js b/src/renderer/constants/action_types.js index 3ffe23e6e..4a2d31e0d 100644 --- a/src/renderer/constants/action_types.js +++ b/src/renderer/constants/action_types.js @@ -117,6 +117,7 @@ export const USER_EMAIL_NEW_FAILURE = 'USER_EMAIL_NEW_FAILURE'; export const USER_EMAIL_VERIFY_STARTED = 'USER_EMAIL_VERIFY_STARTED'; export const USER_EMAIL_VERIFY_SUCCESS = 'USER_EMAIL_VERIFY_SUCCESS'; export const USER_EMAIL_VERIFY_FAILURE = 'USER_EMAIL_VERIFY_FAILURE'; +export const USER_EMAIL_VERIFY_RETRY = 'USER_EMAIL_VERIFY_RETRY'; export const USER_PHONE_RESET = 'USER_PHONE_RESET'; export const USER_PHONE_NEW_STARTED = 'USER_PHONE_NEW_STARTED'; export const USER_PHONE_NEW_SUCCESS = 'USER_PHONE_NEW_SUCCESS'; diff --git a/src/renderer/redux/actions/user.js b/src/renderer/redux/actions/user.js index 8fc5bcb39..1893fb13a 100644 --- a/src/renderer/redux/actions/user.js +++ b/src/renderer/redux/actions/user.js @@ -196,6 +196,38 @@ export function doUserEmailNew(email) { }; } +export function doUserResendVerificationEmail(email) { + return dispatch => { + dispatch({ + type: ACTIONS.USER_EMAIL_VERIFY_RETRY, + email, + }); + + const success = () => { + dispatch({ + type: ACTIONS.USER_EMAIL_NEW_SUCCESS, + data: { email }, + }); + dispatch(doUserFetch()); + }; + + const failure = error => { + dispatch({ + type: ACTIONS.USER_EMAIL_NEW_FAILURE, + data: { error }, + }); + }; + + Lbryio.call('user_email', 'resend_token', { email }, 'post') + .catch(error => { + if (error.response && error.response.status === 409) { + throw error; + } + }) + .then(success, failure); + }; +} + export function doUserEmailVerifyFailure(error) { return { type: ACTIONS.USER_EMAIL_VERIFY_FAILURE, -- 2.45.2 From 937987ba04ba012d9bc5a7f780d1f1c6e28fc856 Mon Sep 17 00:00:00 2001 From: Amit Nandan P Date: Wed, 6 Jun 2018 21:40:32 -0500 Subject: [PATCH 2/5] #1492 Refactoring Fuction Names --- src/renderer/component/userEmailVerify/view.jsx | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/renderer/component/userEmailVerify/view.jsx b/src/renderer/component/userEmailVerify/view.jsx index 408b2d879..f032ea36f 100644 --- a/src/renderer/component/userEmailVerify/view.jsx +++ b/src/renderer/component/userEmailVerify/view.jsx @@ -26,7 +26,7 @@ class UserEmailVerify extends React.PureComponent { }; (this: any).handleSubmit = this.handleSubmit.bind(this); - (this: any).handleResendVerification = this.handleResendVerification.bind(this); + (this: any).handleResendVerificationEmail = this.handleResendVerificationEmail.bind(this); } handleCodeChanged(event: SyntheticInputEvent<*>) { @@ -45,7 +45,7 @@ class UserEmailVerify extends React.PureComponent { } } - handleResendVerification() { + handleResendVerificationEmail() { this.props.resendVerificationEmail(this.props.email); } @@ -80,7 +80,7 @@ class UserEmailVerify extends React.PureComponent {