Skip to content

Commit

Permalink
fix: End request processing correctly
Browse files Browse the repository at this point in the history
  • Loading branch information
johnnynotsolucky committed Nov 27, 2024
1 parent 3bba358 commit 7b386b0
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 8 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Release Notes for honeypot

## 1.0.0-beta.1
## 1.0.0-beta

- Initial beta release
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "fostercommerce/craft-honeypot",
"type": "craft-plugin",
"license": "proprietary",
"version": "1.0.0-beta.1",
"version": "1.0.0-beta.2",
"support": {
"email": "support@fostercommerce.com",
"issues": "https://github.com/fostercommerce/craft-honeypot/issues?state=open",
Expand Down
13 changes: 7 additions & 6 deletions src/Plugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
use craft\helpers\App;
use craft\web\Application;
use craft\web\Request;
use craft\web\Response;
use fostercommerce\honeypot\models\Settings;
use fostercommerce\honeypot\web\twig\Honeypot;
use yii\base\Event;
Expand Down Expand Up @@ -78,16 +79,16 @@ function (Event $event): void {
}

if ($settings->spamDetectedResponse !== false || App::devMode()) {
ob_start();

if ($settings->spamDetectedResponse !== false) {
echo $settings->spamDetectedResponse;
/** @var Response $response */
$response = Craft::$app->getResponse();
if ($settings->spamDetectedResponse !== false && is_string($settings->spamDetectedResponse)) {
$response->content = $settings->spamDetectedResponse;
} else {
echo 'Spam submission detected';
$response->content = 'Spam submission detected';
}
}

exit(0);
Craft::$app->end();
}
}
}
Expand Down

0 comments on commit 7b386b0

Please sign in to comment.