Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add optional reCAPTCHA for registration #335

Open
wants to merge 10 commits into
base: master
Choose a base branch
from
Prev Previous commit
Next Next commit
Get recaptcha token via callback
  • Loading branch information
Kangaroux committed Jul 8, 2020
commit 82596e8ee91aa1a3ea3d258a512df011d5a7296c
10 changes: 9 additions & 1 deletion client/js/views/registration_view.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,22 @@ class RegistrationView extends events.EventTarget {
views.syncScrollPosition();
views.decorateValidator(this._formNode);
this._formNode.addEventListener("submit", (e) => this._evtSubmit(e));
this.setRecaptchaToken = this.setRecaptchaToken.bind(this);
this.renderRecaptcha();
}

renderRecaptcha() {
grecaptcha.render(this._recaptchaNode, {
"sitekey": RECAPTCHA_SITE_KEY
"callback": this.setRecaptchaToken,
"sitekey": RECAPTCHA_SITE_KEY,
});
}

setRecaptchaToken(token) {
console.log("Recaptcha token:", token);
this.recaptchaToken = token;
}

clearMessages() {
views.clearMessages(this._hostNode);
}
Expand All @@ -54,6 +61,7 @@ class RegistrationView extends events.EventTarget {
name: this._userNameFieldNode.value,
password: this._passwordFieldNode.value,
email: this._emailFieldNode.value,
recaptchaToken: this.recaptchaToken,
},
})
);
Expand Down