} } catch (Exception $exc) { echo returnError(400, $exc->getMessage()); } } else { // error echo returnError(404, "Unknown request: [{$http_method} {$resource}]"); } } } } } break; case "login": if ($http_method == "POST" && $param == null) { if (ApiUtils::isLoginSuccessful()) { $returnJson = array('loginSuccess' => true, 'active' => $_SESSION["active"], 'role' => $_SESSION["role"], 'id' => $_SESSION["id"]); } else { $returnJson = array('loginSuccess' => false); } http_response_code(200); echo json_encode($returnJson); } else { // error echo returnError(404, "Unknown request: [{$http_method} {$resource}]"); } break; case "logout": if ($http_method == "GET" && $param == null) { session_start(); session_destroy();