Issue #437: Fixed CSRF-token returning null on first refresh after cookies are removed.

This commit is contained in:
Simon Sessingø
2021-03-18 02:50:06 +01:00
parent 11a69c2f72
commit fb726c3613
3 changed files with 29 additions and 8 deletions
@@ -17,7 +17,7 @@ class CookieTokenProvider implements ITokenProvider
*/
public function __construct()
{
$this->token = $this->getToken();
$this->token = ($this->hasToken() === true) ? $_COOKIE[static::CSRF_KEY] : null;
if ($this->token === null) {
$this->token = $this->generateToken();
@@ -73,8 +73,6 @@ class CookieTokenProvider implements ITokenProvider
*/
public function getToken(?string $defaultValue = null): ?string
{
$this->token = ($this->hasToken() === true) ? $_COOKIE[static::CSRF_KEY] : null;
return $this->token ?? $defaultValue;
}