getBody()->write('BEFORE'); $user = AuthService::getUser(); if (!$user->isLogin) { $newResponse = $response->withStatus(302)->withHeader('Location', '/auth/login'); return $newResponse; } if (!$user->isAdmin()) { $newResponse = $response->withStatus(302)->withHeader('Location', '/user'); return $newResponse; } $response = $next($request, $response); return $response; } }