Recaptcha #886
3 changed files with 32 additions and 14 deletions
|
@ -20,7 +20,8 @@ const select = state => ({
|
|||
});
|
||||
|
||||
const perform = dispatch => ({
|
||||
verifyUserEmail: code => dispatch(doUserEmailVerify(code)),
|
||||
verifyUserEmail: (code, recaptcha) =>
|
||||
dispatch(doUserEmailVerify(code, recaptcha)),
|
||||
});
|
||||
|
||||
export default connect(select, perform)(UserEmailVerify);
|
||||
|
|
|
@ -11,6 +11,7 @@ class UserEmailVerify extends React.PureComponent {
|
|||
|
||||
this.state = {
|
||||
code: "",
|
||||
recaptcha: "",
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -21,8 +22,14 @@ class UserEmailVerify extends React.PureComponent {
|
|||
}
|
||||
|
||||
handleSubmit() {
|
||||
const { code } = this.state;
|
||||
this.props.verifyUserEmail(code);
|
||||
const { code, recaptcha } = this.state;
|
||||
this.props.verifyUserEmail(code, recaptcha);
|
||||
}
|
||||
|
||||
verifyCallback(response) {
|
||||
this.setState({
|
||||
recaptcha: String(response).trim(),
|
||||
});
|
||||
}
|
||||
|
||||
render() {
|
||||
|
@ -46,7 +53,10 @@ class UserEmailVerify extends React.PureComponent {
|
|||
}}
|
||||
errorMessage={errorMessage}
|
||||
/>
|
||||
<Recaptcha sitekey="6LeIxAcTAAAAAJcZVRqyHh71UMIEGNQ_MXjiZKhI" />
|
||||
<Recaptcha
|
||||
sitekey="6LeIxAcTAAAAAJcZVRqyHh71UMIEGNQ_MXjiZKhI"
|
||||
verifyCallback={this.verifyCallback.bind(this)}
|
||||
/>
|
||||
{/* render help separately so it always shows */}
|
||||
<div className="form-field__helper">
|
||||
<p>
|
||||
|
|
|
@ -68,14 +68,14 @@ export function doUserEmailNew(email) {
|
|||
data: { email },
|
||||
});
|
||||
dispatch(doUserFetch());
|
||||
}
|
||||
};
|
||||
|
||||
const failure = error => {
|
||||
dispatch({
|
||||
type: types.USER_EMAIL_NEW_FAILURE,
|
||||
data: { error },
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
lbryio
|
||||
.call(
|
||||
|
@ -86,12 +86,14 @@ export function doUserEmailNew(email) {
|
|||
)
|
||||
.catch(error => {
|
||||
if (error.response && error.response.status == 409) {
|
||||
return lbryio.call(
|
||||
"user_email",
|
||||
"resend_token",
|
||||
{ email: email, only_if_expired: true },
|
||||
"post"
|
||||
).then(success, failure);
|
||||
return lbryio
|
||||
.call(
|
||||
"user_email",
|
||||
"resend_token",
|
||||
{ email: email, only_if_expired: true },
|
||||
"post"
|
||||
)
|
||||
.then(success, failure);
|
||||
}
|
||||
throw error;
|
||||
})
|
||||
|
@ -99,10 +101,11 @@ export function doUserEmailNew(email) {
|
|||
};
|
||||
}
|
||||
|
||||
export function doUserEmailVerify(verificationToken) {
|
||||
export function doUserEmailVerify(verificationToken, recaptcha) {
|
||||
return function(dispatch, getState) {
|
||||
const email = selectEmailToVerify(getState());
|
||||
verificationToken = verificationToken.toString().trim();
|
||||
recaptcha = recaptcha.toString().trim();
|
||||
|
||||
dispatch({
|
||||
type: types.USER_EMAIL_VERIFY_STARTED,
|
||||
|
@ -113,7 +116,11 @@ export function doUserEmailVerify(verificationToken) {
|
|||
.call(
|
||||
"user_email",
|
||||
"confirm",
|
||||
{ verification_token: verificationToken, email: email },
|
||||
{
|
||||
verification_token: verificationToken,
|
||||
email: email,
|
||||
recaptcha: recaptcha,
|
||||
},
|
||||
"post"
|
||||
)
|
||||
.then(userEmail => {
|
||||
|
|
Loading…
Add table
Reference in a new issue