且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何将 Google 的 reCaptcha 集成到 aldeed:autoform (meteor) 中

更新时间:2023-02-07 17:03:33

与其在服务器端方法上抛出错误,不如返回成功值,例如:

Rather than throw the error on your server side method, just return the success value, like:

verifyCaptchaResponse = reCAPTCHA.verifyCaptcha(this.connection.clientAddress, doc.gRecaptchaResponse);

  if (verifyCaptchaResponse.data.success === false) {
    return verifyCaptchaResponse.data;
  }

在回调中返回客户端,执行以下操作:

Than back on the client in the callback, do something like:

if (result && result.success === false) {
      //CAPTCHA failed
      Modal.show('recaptcha');
    }
return false;

与其使用提交表单"事件,不如使用 AutoForm.hooks,然后在您的表单中使用 AutoForm.hooks 中的 onSubmit 方法.

And rather than use a 'submit form' event, use AutoForm.hooks, then use the onSubmit method inside AutoForm.hooks for your form.