Adding ability to resend verification emails #1560

Merged
amitnndn merged 7 commits from master into master 2018-06-08 21:50:53 +02:00
5 changed files with 53 additions and 3 deletions

View file

@ -6,6 +6,8 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/).
## [Unreleased]
### Added
* Add ability to resend verification email ([#1492](https://github.com/lbryio/lbry-app/issues/1492))
* Add Narrative about Feature Request on Help Page and Report Page ([#1551](https://github.com/lbryio/lbry-app/pull/1551))
* Add keyboard shortcut to quit the app on Windows ([#1202](https://github.com/lbryio/lbry-app/pull/1202))
* Build for both architectures (x86 and x64) for Windows ([#1262](https://github.com/lbryio/lbry-app/pull/1262))

View file

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

View file

@ -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<Props, State> {
};
(this: any).handleSubmit = this.handleSubmit.bind(this);
(this: any).handleResendVerificationEmail = this.handleResendVerificationEmail.bind(this);
}
handleCodeChanged(event: SyntheticInputEvent<*>) {
@ -43,6 +45,10 @@ class UserEmailVerify extends React.PureComponent<Props, State> {
}
}
handleResendVerificationEmail() {
this.props.resendVerificationEmail(this.props.email);
}
render() {
const { cancelButton, errorMessage, email, isPending } = this.props;
@ -71,6 +77,11 @@ class UserEmailVerify extends React.PureComponent<Props, State> {
<div className="card__actions">
<Submit label={__('Verify')} disabled={isPending} />
{cancelButton}
<Button
button="link"
label={__('Resend verification email')}
onClick={this.handleResendVerificationEmail}
/>
</div>
</Form>
);

View file

@ -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';

View file

@ -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,