mirror of
https://github.com/flarum/framework.git
synced 2025-01-22 13:05:32 +08:00
Extract method
This commit is contained in:
parent
fc168ef675
commit
9786568749
|
@ -33,9 +33,7 @@ class StartSession implements MiddlewareInterface
|
|||
|
||||
$response = $out ? $out($request, $response) : $response;
|
||||
|
||||
if ($session->has('csrf_token')) {
|
||||
$response = $response->withHeader('X-CSRF-Token', $session->get('csrf_token'));
|
||||
}
|
||||
$response = $this->withCsrfTokenHeader($response, $session);
|
||||
|
||||
return $this->withSessionCookie($response, $session);
|
||||
}
|
||||
|
@ -54,6 +52,15 @@ class StartSession implements MiddlewareInterface
|
|||
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)
|
||||
{
|
||||
return FigResponseCookies::set(
|
||||
|
|
Loading…
Reference in New Issue
Block a user