Recaptcha #886

Closed
liamcardenas wants to merge 5 commits from recaptcha into master
3 changed files with 32 additions and 14 deletions
Showing only changes of commit 33336256d0 - Show all commits

View file

@ -20,7 +20,8 @@ const select = state => ({
}); });
const perform = dispatch => ({ const perform = dispatch => ({
verifyUserEmail: code => dispatch(doUserEmailVerify(code)), verifyUserEmail: (code, recaptcha) =>
dispatch(doUserEmailVerify(code, recaptcha)),
}); });
export default connect(select, perform)(UserEmailVerify); export default connect(select, perform)(UserEmailVerify);

View file

@ -11,6 +11,7 @@ class UserEmailVerify extends React.PureComponent {
this.state = { this.state = {
code: "", code: "",
recaptcha: "",
}; };
} }
@ -21,8 +22,14 @@ class UserEmailVerify extends React.PureComponent {
} }
handleSubmit() { handleSubmit() {
const { code } = this.state; const { code, recaptcha } = this.state;
this.props.verifyUserEmail(code); this.props.verifyUserEmail(code, recaptcha);
}
verifyCallback(response) {
this.setState({
recaptcha: String(response).trim(),
});
} }
render() { render() {
@ -46,7 +53,10 @@ class UserEmailVerify extends React.PureComponent {
}} }}
errorMessage={errorMessage} errorMessage={errorMessage}
/> />
<Recaptcha sitekey="6LeIxAcTAAAAAJcZVRqyHh71UMIEGNQ_MXjiZKhI" /> <Recaptcha
sitekey="6LeIxAcTAAAAAJcZVRqyHh71UMIEGNQ_MXjiZKhI"
verifyCallback={this.verifyCallback.bind(this)}
/>
{/* render help separately so it always shows */} {/* render help separately so it always shows */}
<div className="form-field__helper"> <div className="form-field__helper">
<p> <p>

View file

@ -68,14 +68,14 @@ export function doUserEmailNew(email) {
data: { email }, data: { email },
}); });
dispatch(doUserFetch()); dispatch(doUserFetch());
} };
const failure = error => { const failure = error => {
dispatch({ dispatch({
type: types.USER_EMAIL_NEW_FAILURE, type: types.USER_EMAIL_NEW_FAILURE,
data: { error }, data: { error },
}); });
} };
lbryio lbryio
.call( .call(
@ -86,12 +86,14 @@ export function doUserEmailNew(email) {
) )
.catch(error => { .catch(error => {
if (error.response && error.response.status == 409) { if (error.response && error.response.status == 409) {
return lbryio.call( return lbryio
"user_email", .call(
"resend_token", "user_email",
{ email: email, only_if_expired: true }, "resend_token",
"post" { email: email, only_if_expired: true },
).then(success, failure); "post"
)
.then(success, failure);
} }
throw error; throw error;
}) })
@ -99,10 +101,11 @@ export function doUserEmailNew(email) {
}; };
} }
export function doUserEmailVerify(verificationToken) { export function doUserEmailVerify(verificationToken, recaptcha) {
return function(dispatch, getState) { return function(dispatch, getState) {
const email = selectEmailToVerify(getState()); const email = selectEmailToVerify(getState());
verificationToken = verificationToken.toString().trim(); verificationToken = verificationToken.toString().trim();
recaptcha = recaptcha.toString().trim();
dispatch({ dispatch({
type: types.USER_EMAIL_VERIFY_STARTED, type: types.USER_EMAIL_VERIFY_STARTED,
@ -113,7 +116,11 @@ export function doUserEmailVerify(verificationToken) {
.call( .call(
"user_email", "user_email",
"confirm", "confirm",
{ verification_token: verificationToken, email: email }, {
verification_token: verificationToken,
email: email,
recaptcha: recaptcha,
},
"post" "post"
) )
.then(userEmail => { .then(userEmail => {