function checkToken() { $app = \Slim\Slim::getInstance(); $token = $app->request->headers->get('token'); $app = \Slim\Slim::getInstance(); if ($token) { $db = new dbHandler(); if ($db->isValidToken($token)) { return true; } else { sendResponse(401, initBody(true, "Bad token"), null); $app->stop(); } } else { sendResponse(401, initBody(true, "Token is missing"), null); $app->stop(); } }