#1492 Adding support to resend verification email
This commit is contained in:
parent
c61392e9f3
commit
8c343b16e3
4 changed files with 51 additions and 3 deletions
|
@ -1,6 +1,9 @@
|
||||||
import React from 'react';
|
|
||||||
import { connect } from 'react-redux';
|
import { connect } from 'react-redux';
|
||||||
import { doUserEmailVerify, doUserEmailVerifyFailure } from 'redux/actions/user';
|
import {
|
||||||
|
doUserEmailVerify,
|
||||||
|
doUserEmailVerifyFailure,
|
||||||
|
doUserResendVerificationEmail,
|
||||||
|
} from 'redux/actions/user';
|
||||||
import {
|
import {
|
||||||
selectEmailVerifyIsPending,
|
selectEmailVerifyIsPending,
|
||||||
selectEmailToVerify,
|
selectEmailToVerify,
|
||||||
|
@ -17,6 +20,7 @@ const select = state => ({
|
||||||
const perform = dispatch => ({
|
const perform = dispatch => ({
|
||||||
verifyUserEmail: (code, recaptcha) => dispatch(doUserEmailVerify(code, recaptcha)),
|
verifyUserEmail: (code, recaptcha) => dispatch(doUserEmailVerify(code, recaptcha)),
|
||||||
verifyUserEmailFailure: error => dispatch(doUserEmailVerifyFailure(error)),
|
verifyUserEmailFailure: error => dispatch(doUserEmailVerifyFailure(error)),
|
||||||
|
resendVerificationEmail: email => dispatch(doUserResendVerificationEmail(email)),
|
||||||
});
|
});
|
||||||
|
|
||||||
export default connect(select, perform)(UserEmailVerify);
|
export default connect(select, perform)(UserEmailVerify);
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
// @flow
|
// @flow
|
||||||
import React from 'react';
|
import * as React from 'react';
|
||||||
import Button from 'component/button';
|
import Button from 'component/button';
|
||||||
import { Form, FormField, FormRow, Submit } from 'component/common/form';
|
import { Form, FormField, FormRow, Submit } from 'component/common/form';
|
||||||
|
|
||||||
|
@ -10,6 +10,7 @@ type Props = {
|
||||||
isPending: boolean,
|
isPending: boolean,
|
||||||
verifyUserEmail: (string, string) => void,
|
verifyUserEmail: (string, string) => void,
|
||||||
verifyUserEmailFailure: string => void,
|
verifyUserEmailFailure: string => void,
|
||||||
|
resendVerificationEmail: string => void,
|
||||||
};
|
};
|
||||||
|
|
||||||
type State = {
|
type State = {
|
||||||
|
@ -25,6 +26,7 @@ class UserEmailVerify extends React.PureComponent<Props, State> {
|
||||||
};
|
};
|
||||||
|
|
||||||
(this: any).handleSubmit = this.handleSubmit.bind(this);
|
(this: any).handleSubmit = this.handleSubmit.bind(this);
|
||||||
|
(this: any).handleResendVerification = this.handleResendVerification.bind(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
handleCodeChanged(event: SyntheticInputEvent<*>) {
|
handleCodeChanged(event: SyntheticInputEvent<*>) {
|
||||||
|
@ -43,6 +45,10 @@ class UserEmailVerify extends React.PureComponent<Props, State> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
handleResendVerification() {
|
||||||
|
this.props.resendVerificationEmail(this.props.email);
|
||||||
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
const { cancelButton, errorMessage, email, isPending } = this.props;
|
const { cancelButton, errorMessage, email, isPending } = this.props;
|
||||||
|
|
||||||
|
@ -71,6 +77,11 @@ class UserEmailVerify extends React.PureComponent<Props, State> {
|
||||||
<div className="card__actions">
|
<div className="card__actions">
|
||||||
<Submit label={__('Verify')} disabled={isPending} />
|
<Submit label={__('Verify')} disabled={isPending} />
|
||||||
{cancelButton}
|
{cancelButton}
|
||||||
|
<Button
|
||||||
|
button="inverse"
|
||||||
|
label={__('Resend Verification Email')}
|
||||||
|
onClick={this.handleResendVerification}
|
||||||
|
/>
|
||||||
</div>
|
</div>
|
||||||
</Form>
|
</Form>
|
||||||
);
|
);
|
||||||
|
|
|
@ -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_STARTED = 'USER_EMAIL_VERIFY_STARTED';
|
||||||
export const USER_EMAIL_VERIFY_SUCCESS = 'USER_EMAIL_VERIFY_SUCCESS';
|
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_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_RESET = 'USER_PHONE_RESET';
|
||||||
export const USER_PHONE_NEW_STARTED = 'USER_PHONE_NEW_STARTED';
|
export const USER_PHONE_NEW_STARTED = 'USER_PHONE_NEW_STARTED';
|
||||||
export const USER_PHONE_NEW_SUCCESS = 'USER_PHONE_NEW_SUCCESS';
|
export const USER_PHONE_NEW_SUCCESS = 'USER_PHONE_NEW_SUCCESS';
|
||||||
|
|
|
@ -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) {
|
export function doUserEmailVerifyFailure(error) {
|
||||||
return {
|
return {
|
||||||
type: ACTIONS.USER_EMAIL_VERIFY_FAILURE,
|
type: ACTIONS.USER_EMAIL_VERIFY_FAILURE,
|
||||||
|
|
Loading…
Add table
Reference in a new issue