function authenticateToken() { global $db; $app = \Slim\Slim::getInstance(); $headers = apache_request_headers(); $token; foreach ($headers as $header => $value) { if ($header == 'Authorization') { $token = str_replace('"', "", $value); } } $tokenFromDB = Users_model::get_user_by_token($db, $token); if (!$tokenFromDB) { echoResponse(403, $token); exit; } }