Skip to content

Commit

Permalink
Don't pass by reference.
Browse files Browse the repository at this point in the history
  • Loading branch information
ADmad committed Apr 21, 2017
1 parent 12fc9b1 commit 80208ca
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/Http/Middleware/CsrfProtectionMiddleware.php
Expand Up @@ -102,7 +102,7 @@ public function __invoke(ServerRequestInterface $request, ResponseInterface $res

$method = $request->getMethod();
if ($method === 'GET' && $cookieData === null) {
$this->_setToken($request, $response);
list($request, $response) = $this->_setToken($request, $response);

return $next($request, $response);
}
Expand Down Expand Up @@ -140,9 +140,9 @@ protected function _validateAndUnsetTokenField(ServerRequestInterface $request)
*
* @param \Psr\Http\Message\ServerRequestInterface $request The request object.
* @param \Psr\Http\Message\ResponseInterface $response The response object.
* @return void
* @return array
*/
protected function _setToken(ServerRequestInterface &$request, ResponseInterface &$response)
protected function _setToken(ServerRequestInterface $request, ResponseInterface $response)
{
$expiry = new Time($this->_config['expiry']);
$value = hash('sha512', Security::randomBytes(16), false);
Expand All @@ -158,6 +158,8 @@ protected function _setToken(ServerRequestInterface &$request, ResponseInterface
'secure' => $this->_config['secure'],
'httpOnly' => $this->_config['httpOnly'],
]);

return [$request, $response];
}

/**
Expand Down

0 comments on commit 80208ca

Please sign in to comment.