mirror of
https://github.com/flarum/core.git
synced 2025-07-29 20:50:28 +02:00
Extract method
This commit is contained in:
@@ -33,9 +33,7 @@ class StartSession implements MiddlewareInterface
|
|||||||
|
|
||||||
$response = $out ? $out($request, $response) : $response;
|
$response = $out ? $out($request, $response) : $response;
|
||||||
|
|
||||||
if ($session->has('csrf_token')) {
|
$response = $this->withCsrfTokenHeader($response, $session);
|
||||||
$response = $response->withHeader('X-CSRF-Token', $session->get('csrf_token'));
|
|
||||||
}
|
|
||||||
|
|
||||||
return $this->withSessionCookie($response, $session);
|
return $this->withSessionCookie($response, $session);
|
||||||
}
|
}
|
||||||
@@ -54,6 +52,15 @@ class StartSession implements MiddlewareInterface
|
|||||||
return $session;
|
return $session;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private function withCsrfTokenHeader(Response $response, SessionInterface $session)
|
||||||
|
{
|
||||||
|
if ($session->has('csrf_token')) {
|
||||||
|
$response = $response->withHeader('X-CSRF-Token', $session->get('csrf_token'));
|
||||||
|
}
|
||||||
|
|
||||||
|
return $response;
|
||||||
|
}
|
||||||
|
|
||||||
private function withSessionCookie(Response $response, SessionInterface $session)
|
private function withSessionCookie(Response $response, SessionInterface $session)
|
||||||
{
|
{
|
||||||
return FigResponseCookies::set(
|
return FigResponseCookies::set(
|
||||||
|
Reference in New Issue
Block a user