Skip to content

Commit

Permalink
Fix CSRF tokens with non GET requests
Browse files Browse the repository at this point in the history
  • Loading branch information
bencroker committed Aug 8, 2024
1 parent a476a2b commit e9011bc
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 2 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Release Notes for Sprig Core

## 3.3.1 - 2024-08-08

### Fixed

- Fixed CSRF tokens not being sent with requests using a method other than `GET`.

## 3.3.0 - 2024-08-08

### Added
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "putyourlightson/craft-sprig-core",
"description": "A reactive Twig component framework for Craft.",
"version": "3.3.0",
"version": "3.3.1",
"type": "craft-module",
"license": "mit",
"require": {
Expand Down
2 changes: 1 addition & 1 deletion src/services/ComponentsService.php
Original file line number Diff line number Diff line change
Expand Up @@ -429,7 +429,7 @@ private function parseSprigAttribute(array &$attributes): void
$params = [];
$method = strtolower($this->getSprigAttributeValue($attributes, 'method', 'get'));

if ($method === 'post') {
if ($method !== 'get') {
$this->mergeJsonAttributes($attributes, 'headers', [
Request::CSRF_HEADER => Craft::$app->getRequest()->getCsrfToken(),
]);
Expand Down

0 comments on commit e9011bc

Please sign in to comment.