Skip to content

Commit

Permalink
allow better recaptcha error handling, originally #267 (#286)
Browse files Browse the repository at this point in the history
* allow better recaptcha error handling, originally #267
  • Loading branch information
solverat authored May 25, 2021
1 parent e157bb5 commit a61464a
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 13 deletions.
1 change: 1 addition & 0 deletions UPGRADE.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ Just click the "update" button or execute the migration command to finish the bu
- **[IMPROVEMENT]**: Adjust field attribute label "Preselected" [#270](https://github.com/dachcom-digital/pimcore-formbuilder/issues/270)
- **[IMPROVEMENT]**: Field name preview added [#237](https://github.com/dachcom-digital/pimcore-formbuilder/issues/237)
- **[IMPROVEMENT]**: Added `CRM/Firstname`, `CRM/Lastname`, `CRM/Email`, `CRM/NewsletterActive`, `CRM/NewsletterConfirmed`, `CRM/Consent`, `Number/Slider`, `CRM/Gender` fields to allowed object mapping types [#238](https://github.com/dachcom-digital/pimcore-formbuilder/issues/238)
- **[IMPROVEMENT]**: Adds fatal error event for captcha [@patric-eberle](https://github.com/dachcom-digital/pimcore-formbuilder/pull/267)
- **[BUGFIX]**: Remove `body` param from mail object after rendering [#268](https://github.com/dachcom-digital/pimcore-formbuilder/issues/268)
- **[BUGFIX]**: Fix container toggle in conditional logic

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,13 @@
},

injectTokenToForm: function () {
grecaptcha.execute(this.siteKey, {action: this.action}).then(this.onTokenGenerated.bind(this));
try {
grecaptcha.execute(this.siteKey, {action: this.action}).then(this.onTokenGenerated.bind(this), function () {
this.$form.trigger('formbuilder.fatal-captcha', [null]);
}.bind(this));
} catch (error) {
this.$form.trigger('formbuilder.fatal-captcha', [error]);
}
},

/**
Expand Down
4 changes: 2 additions & 2 deletions tests/acceptance/Constraints/DropZoneConstraintsCest.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class DropZoneConstraintsCest
*/
public function testEmptyFileUploadFormWithNotBlankConstraint(AcceptanceTester $I)
{
$I->haveABootedSymfonyConfiguration('config_dropzonejs.yml');
$I->haveABootedSymfonyConfiguration('config_dropzonejs.yml', true);

$testFormBuilder = (new TestFormBuilder('dachcom_test'))
->setUseAjax(true)
Expand Down Expand Up @@ -44,7 +44,7 @@ public function testEmptyFileUploadFormWithNotBlankConstraint(AcceptanceTester $
*/
public function testPopulatedFileUploadFormWithNotBlankConstraint(AcceptanceTester $I)
{
$I->haveABootedSymfonyConfiguration('config_dropzonejs.yml');
$I->haveABootedSymfonyConfiguration('config_dropzonejs.yml', true);

$testFormBuilder = (new TestFormBuilder('dachcom_test'))
->setUseAjax(true)
Expand Down
20 changes: 10 additions & 10 deletions tests/acceptance/Form/DropZoneJsCest.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class DropZoneJsCest
*/
public function testUploadFormWithOneFile(AcceptanceTester $I)
{
$I->haveABootedSymfonyConfiguration('config_dropzonejs.yml');
$I->haveABootedSymfonyConfiguration('config_dropzonejs.yml', true);

$testFormBuilder = $this->generateSimpleForm(true);

Expand Down Expand Up @@ -57,7 +57,7 @@ public function testUploadFormWithOneFile(AcceptanceTester $I)
*/
public function testUploadFormWithOneLargeFile(AcceptanceTester $I)
{
$I->haveABootedSymfonyConfiguration('config_dropzonejs.yml');
$I->haveABootedSymfonyConfiguration('config_dropzonejs.yml', true);

$testFormBuilder = $this->generateSimpleForm(true);

Expand Down Expand Up @@ -97,7 +97,7 @@ public function testUploadFormWithOneLargeFile(AcceptanceTester $I)
*/
public function testUploadFormWithMultipleFile(AcceptanceTester $I)
{
$I->haveABootedSymfonyConfiguration('config_dropzonejs.yml');
$I->haveABootedSymfonyConfiguration('config_dropzonejs.yml', true);

$testFormBuilder = $this->generateSimpleForm(true);

Expand Down Expand Up @@ -141,7 +141,7 @@ public function testUploadFormWithMultipleFile(AcceptanceTester $I)
*/
public function testUploadFormWithLimitedAllowedExtensionsMustPass(AcceptanceTester $I)
{
$I->haveABootedSymfonyConfiguration('config_dropzonejs.yml');
$I->haveABootedSymfonyConfiguration('config_dropzonejs.yml', true);

$testFormBuilder = $this->generateSimpleForm(true);

Expand Down Expand Up @@ -190,7 +190,7 @@ public function testUploadFormWithLimitedAllowedExtensionsMustPass(AcceptanceTes
*/
public function testUploadFormWithLimitedAllowedExtensionsMustFail(AcceptanceTester $I)
{
$I->haveABootedSymfonyConfiguration('config_dropzonejs.yml');
$I->haveABootedSymfonyConfiguration('config_dropzonejs.yml', true);

$testFormBuilder = $this->generateSimpleForm(true);

Expand Down Expand Up @@ -236,7 +236,7 @@ public function testUploadFormWithLimitedAllowedExtensionsMustFail(AcceptanceTes
*/
public function testUploadFormWithLimitedItemsLimitMustPass(AcceptanceTester $I)
{
$I->haveABootedSymfonyConfiguration('config_dropzonejs.yml');
$I->haveABootedSymfonyConfiguration('config_dropzonejs.yml', true);

$testFormBuilder = $this->generateSimpleForm(true);

Expand Down Expand Up @@ -284,7 +284,7 @@ public function testUploadFormWithLimitedItemsLimitMustPass(AcceptanceTester $I)
*/
public function testUploadFormWithLimitedItemsLimitMustFail(AcceptanceTester $I)
{
$I->haveABootedSymfonyConfiguration('config_dropzonejs.yml');
$I->haveABootedSymfonyConfiguration('config_dropzonejs.yml', true);

$testFormBuilder = $this->generateSimpleForm(true);

Expand Down Expand Up @@ -334,7 +334,7 @@ public function testUploadFormWithLimitedItemsLimitMustFail(AcceptanceTester $I)
*/
public function testUploadFormWithLimitedFileSizeMustPass(AcceptanceTester $I)
{
$I->haveABootedSymfonyConfiguration('config_dropzonejs.yml');
$I->haveABootedSymfonyConfiguration('config_dropzonejs.yml', true);

$testFormBuilder = $this->generateSimpleForm(true);

Expand Down Expand Up @@ -382,7 +382,7 @@ public function testUploadFormWithLimitedFileSizeMustPass(AcceptanceTester $I)
*/
public function testUploadFormWithLimitedFileSizeMustFail(AcceptanceTester $I)
{
$I->haveABootedSymfonyConfiguration('config_dropzonejs.yml');
$I->haveABootedSymfonyConfiguration('config_dropzonejs.yml', true);

$testFormBuilder = $this->generateSimpleForm(true);

Expand Down Expand Up @@ -427,7 +427,7 @@ public function testUploadFormWithLimitedFileSizeMustFail(AcceptanceTester $I)
*/
public function testUploadFormWithFilesAsAttachment(AcceptanceTester $I)
{
$I->haveABootedSymfonyConfiguration('config_dropzonejs.yml');
$I->haveABootedSymfonyConfiguration('config_dropzonejs.yml', true);

$testFormBuilder = $this->generateSimpleForm(true);

Expand Down

0 comments on commit a61464a

Please sign in to comment.