Skip to content

Commit

Permalink
Fixes CSRF not set on first request
Browse files Browse the repository at this point in the history
  • Loading branch information
Schlaefer committed Mar 15, 2020
1 parent 7ca853d commit 1553bba
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/View/Helper/JsDataHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -108,8 +108,9 @@ protected function _getCsrf(View $View)
{
$key = Configure::read('Session.cookie') . '-CSRF';
$token = $View->getRequest()->getCookie($key);
if (is_array($token)) {
// @bogus In which situation is that not a string or null?
if ($token === null) {
// First request without CSRF cookie set yet. CSRF set as new cookie
// in this request.
$token = $View->getResponse()->getCookie($key)['value'];
}
$header = 'X-CSRF-Token';
Expand Down

0 comments on commit 1553bba

Please sign in to comment.