(w http.ResponseWriter, r *http.Request, userID, ibID string)
| 407 | } |
| 408 | |
| 409 | func (a *userAPI) handleUserInbound(w http.ResponseWriter, r *http.Request, userID, ibID string) { |
| 410 | switch r.Method { |
| 411 | case http.MethodGet: |
| 412 | acc, err := a.users.GetUserInbound(ibID) |
| 413 | if err != nil { |
| 414 | writeUserInboundError(w, err) |
| 415 | return |
| 416 | } |
| 417 | if acc.UserID != userID { |
| 418 | writeJSON(w, http.StatusNotFound, map[string]any{"error": "user inbound not found"}) |
| 419 | return |
| 420 | } |
| 421 | writeJSON(w, http.StatusOK, acc) |
| 422 | case http.MethodDelete: |
| 423 | acc, err := a.users.GetUserInbound(ibID) |
| 424 | if err != nil { |
| 425 | writeUserInboundError(w, err) |
| 426 | return |
| 427 | } |
| 428 | if acc.UserID != userID { |
| 429 | writeJSON(w, http.StatusNotFound, map[string]any{"error": "user inbound not found"}) |
| 430 | return |
| 431 | } |
| 432 | if err := a.users.DeleteUserInbound(ibID); err != nil { |
| 433 | writeUserInboundError(w, err) |
| 434 | return |
| 435 | } |
| 436 | a.applyNodes([]string{acc.NodeID}) |
| 437 | writeJSON(w, http.StatusOK, map[string]any{"deleted": true}) |
| 438 | default: |
| 439 | writeMethodNotAllowed(w, http.MethodGet+", "+http.MethodDelete) |
| 440 | } |
| 441 | } |
| 442 | |
| 443 | // handleUserCredentials 管理用户全局凭证(UUID / Secret)。 |
| 444 | // GET 返回当前凭证;PUT 更新凭证(留空则重新随机生成),随后触发全节点配置下发。 |
no test coverage detected