Ejemplo n.º 1
0
    echoResponse(200, $rows);
});
$app->put('/users/:id', 'authenticateToken', function ($id) use($app) {
    global $db;
    $data = json_decode($app->request->getBody());
    $rows = Users_model::update_user($db, $data, $id);
    if ($rows["status"] == "success") {
        $rows["message"] = "User information updated successfully.";
    }
    echoResponse(200, $rows);
});
$app->put('/users/:role/:id', 'authenticateToken', function ($role, $id) use($app) {
    global $db;
    $data = json_decode($app->request->getBody());
    $data->user_id = $id;
    $rows = Users_model::update_userRole($db, $data, $role);
    if ($rows["status"] == "success") {
        $rows["message"] = "User information updated successfully.";
    }
    echoResponse(200, $rows);
});
$app->delete('/users/:role/:id', 'authenticateToken', function ($role, $id) use($app) {
    global $db;
    $rows = Users_model::delete_user($db, $id, $role);
    if ($rows["status"] == "success") {
        $rows["message"] = "User information updated successfully.";
    }
    echoResponse(200, $rows);
});
$app->post('/host', 'authenticateToken', function () use($app) {
    global $db;