Skip to content

Commit

Permalink
Merge branch 'release/2.0.3'
Browse files Browse the repository at this point in the history
  • Loading branch information
adrenth committed Sep 24, 2021
2 parents d6837fa + f4205b6 commit fda0e2a
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 3 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [2.0.3] - 2021-09-24

### Fixes
- Fixes type error when using `csrf_token()` Twig function.

## [2.0.2] - 2021-09-14

### Changed
Expand Down
9 changes: 7 additions & 2 deletions Plugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

use Cms\Classes\CmsController;
use System\Classes\PluginBase;
use Throwable;
use Vdlp\Csrf\Middleware\VerifyCsrfTokenMiddleware;
use Vdlp\Csrf\ServiceProviders\CsrfServiceProvider;

Expand Down Expand Up @@ -38,8 +39,12 @@ public function registerMarkupTags(): array
{
return [
'functions' => [
'csrf_token' => static function (): string {
return csrf_token();
'csrf_token' => static function (): ?string {
try {
return csrf_token();
} catch (Throwable $exception) {
return null;
}
},
],
];
Expand Down
4 changes: 3 additions & 1 deletion middleware/VerifyCsrfTokenMiddleware.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
use Illuminate\Contracts\Encryption\DecryptException;
use Illuminate\Contracts\Encryption\Encrypter;
use Illuminate\Contracts\Routing\ResponseFactory;
use Illuminate\Http\JsonResponse;
use Illuminate\Http\RedirectResponse;
use Illuminate\Http\Request;
use Illuminate\Routing\Redirector;
use October\Rain\Cookie\Middleware\EncryptCookies;
Expand All @@ -34,7 +36,7 @@ public function __construct(
}

/**
* @return \Illuminate\Http\JsonResponse|\Illuminate\Http\RedirectResponse|mixed
* @return JsonResponse|RedirectResponse|mixed
* @throws RuntimeException
*/
public function handle(Request $request, Closure $next)
Expand Down
1 change: 1 addition & 0 deletions updates/version.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@
2.0.0: "Support for PHP 7.4 or higher"
2.0.1: "Fix location of plugin config.php file"
2.0.2: "Minor improvements -- See: CHANGELOG.md"
2.0.3: "Fixes type error when using `csrf_token()` Twig function"

0 comments on commit fda0e2a

Please sign in to comment.