getHeader('Authorization'); if ($jwt) { if (JWTToken::validateJWT($jwt)) { $data = JWTToken::validateJWT($jwt); $data = json_decode($data); if ($data->status) { // $auth = $request->getHeader("Authorization"); return true; }else{ header('Content-Type: application/json'); http_response_code(401); $error = json_encode(["status" => 401, "message" => $data->message]); echo $error; exit; } } } else { header('Content-Type: application/json'); http_response_code(403); $error = json_encode(["status" => 403, "message" => "Access Forbidden!"]); echo $error; exit(); } } public function after(RequestInterface $request, ResponseInterface $response, $arguments = null) { // Do something here after the response is sent } }