Get recaptcha token via callback

This commit is contained in:
Jesse 2020-07-08 03:29:23 -04:00
parent 3c6a3f1d30
commit 82596e8ee9
No known key found for this signature in database
GPG key ID: 1A8AB3257B32D91F

View file

@ -21,15 +21,22 @@ class RegistrationView extends events.EventTarget {
views.syncScrollPosition(); views.syncScrollPosition();
views.decorateValidator(this._formNode); views.decorateValidator(this._formNode);
this._formNode.addEventListener("submit", (e) => this._evtSubmit(e)); this._formNode.addEventListener("submit", (e) => this._evtSubmit(e));
this.setRecaptchaToken = this.setRecaptchaToken.bind(this);
this.renderRecaptcha(); this.renderRecaptcha();
} }
renderRecaptcha() { renderRecaptcha() {
grecaptcha.render(this._recaptchaNode, { 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() { clearMessages() {
views.clearMessages(this._hostNode); views.clearMessages(this._hostNode);
} }
@ -54,6 +61,7 @@ class RegistrationView extends events.EventTarget {
name: this._userNameFieldNode.value, name: this._userNameFieldNode.value,
password: this._passwordFieldNode.value, password: this._passwordFieldNode.value,
email: this._emailFieldNode.value, email: this._emailFieldNode.value,
recaptchaToken: this.recaptchaToken,
}, },
}) })
); );