reCaptcha Aldeed:自动表单(流星)-无法正常工作?

时间:2018-07-02 09:55:05

标签: meteor recaptcha

我对此人有类似的问题: How do I integrate Google's reCaptcha inside aldeed:autoform (meteor)

我尝试了那里提供的解决方案,但是没有用。 在我的contact.js上:

    AutoForm.hooks({
    App_kontakt: {
        onSubmit: function (formData, recaptchaResponse) {
             var formData = {
            //get the data from your form fields
        };

        //get the captcha data
        var recaptchaResponse = grecaptcha.getResponse();

        Meteor.call('formSubmissionMethod', formData, recaptchaResponse, function(error, result) {
            if (result && result.success === false) {
      //CAPTCHA failed
      Modal.show('recaptcha');
    }
return false;

        });

在我的main.js(服务器端)

 Meteor.methods({
formSubmissionMethod: function(formData, captchaData) {

        var verifyCaptchaResponse = reCAPTCHA.verifyCaptcha(this.connection.clientAddress, captchaData);

        if (!verifyCaptchaResponse.success) {
            console.log('reCAPTCHA check failed!', verifyCaptchaResponse);
            throw new Meteor.Error(422, 'reCAPTCHA Failed: ' + verifyCaptchaResponse.error);
        } else
            console.log('reCAPTCHA verification passed!');

        //do stuff with your formData

        return true;
    },
  sendEmail: function(doc) {

    // Build the e-mail text
    var text = "Name: " + doc.name + "\n\n"
            + "E-Mail: " + doc.email + "\n\n\n\n"
            + "Telefonnummer: " + doc.phone + "\n\n"
            + doc.message;

    this.unblock();

    // Send the e-mail
    //Email.send({
      //  to: "....",
       // from: doc.email,
      //  subject: "Neue Nachricht von: " + doc.name,
     //   text: text
  //  });
  //
  console.log('SENT!!!');
  }
});

我只是想不出一个解决方案。我可以解决reCaptcha,但是我是否愿意都没有关系。该表格仍会发送... 由于另一个线程来自2015年,我将创建另一个。

0 个答案:

没有答案