mirror of
https://github.com/flarum/core.git
synced 2025-05-10 17:35:25 +02:00
Extract method
This commit is contained in:
parent
1cac48f90a
commit
aa516fb5c3
@ -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(
|
||||||
|
Loading…
x
Reference in New Issue
Block a user