feat: enhance error handling and permissions in Admin and Report services
This commit is contained in:
@@ -56,8 +56,19 @@ void sendAdmin(Json::Value body,
|
||||
}
|
||||
|
||||
const auto error = body.get("error", "").asString();
|
||||
const auto status = error == "forbidden" ? drogon::k403Forbidden
|
||||
: drogon::k400BadRequest;
|
||||
drogon::HttpStatusCode status = drogon::k400BadRequest;
|
||||
if (error == "forbidden" || error.rfind("cannot_", 0) == 0)
|
||||
{
|
||||
status = drogon::k403Forbidden;
|
||||
}
|
||||
else if (error.ends_with("_not_found"))
|
||||
{
|
||||
status = drogon::k404NotFound;
|
||||
}
|
||||
else if (error == "invalid_status_transition")
|
||||
{
|
||||
status = drogon::k409Conflict;
|
||||
}
|
||||
callback(visione::http::json(std::move(body), status));
|
||||
}
|
||||
} // namespace
|
||||
|
||||
Reference in New Issue
Block a user