feat: ship minecraft theme updates and platform workflow improvements
这个提交包含在:
@@ -192,6 +192,42 @@ void AdminController::updateUserRating(
|
||||
}
|
||||
}
|
||||
|
||||
void AdminController::deleteUser(
|
||||
const drogon::HttpRequestPtr& req,
|
||||
std::function<void(const drogon::HttpResponsePtr&)>&& cb,
|
||||
int64_t user_id) {
|
||||
try {
|
||||
const auto admin_user_id = RequireAdminUserId(req, cb);
|
||||
if (!admin_user_id.has_value()) return;
|
||||
|
||||
if (*admin_user_id == user_id) {
|
||||
cb(JsonError(drogon::k400BadRequest, "cannot delete current admin user"));
|
||||
return;
|
||||
}
|
||||
|
||||
services::UserService users(csp::AppState::Instance().db());
|
||||
const auto target = users.GetById(user_id);
|
||||
if (!target.has_value()) {
|
||||
cb(JsonError(drogon::k404NotFound, "user not found"));
|
||||
return;
|
||||
}
|
||||
if (target->username == "admin") {
|
||||
cb(JsonError(drogon::k400BadRequest, "cannot delete reserved admin user"));
|
||||
return;
|
||||
}
|
||||
|
||||
users.DeleteUser(user_id);
|
||||
|
||||
Json::Value payload;
|
||||
payload["id"] = Json::Int64(user_id);
|
||||
payload["username"] = target->username;
|
||||
payload["deleted"] = true;
|
||||
cb(JsonOk(payload));
|
||||
} catch (const std::exception& e) {
|
||||
cb(JsonError(drogon::k500InternalServerError, e.what()));
|
||||
}
|
||||
}
|
||||
|
||||
void AdminController::listRedeemItems(
|
||||
const drogon::HttpRequestPtr& req,
|
||||
std::function<void(const drogon::HttpResponsePtr&)>&& cb) {
|
||||
|
||||
在新工单中引用
屏蔽一个用户