HandleDashboardAgents lists agents owned by the authenticated user.
(w http.ResponseWriter, r *http.Request)
| 588 | |
| 589 | // HandleDashboardAgents lists agents owned by the authenticated user. |
| 590 | func (ua *UserAuth) HandleDashboardAgents(w http.ResponseWriter, r *http.Request) { |
| 591 | user := ua.AuthenticateRequest(r) |
| 592 | if user == nil { |
| 593 | http.Error(w, "not authenticated", http.StatusUnauthorized) |
| 594 | return |
| 595 | } |
| 596 | |
| 597 | agents, err := ua.store.ListAgentsByUser(r.Context(), user.ID) |
| 598 | if err != nil { |
| 599 | http.Error(w, "failed to list agents", http.StatusInternalServerError) |
| 600 | return |
| 601 | } |
| 602 | |
| 603 | if agents == nil { |
| 604 | agents = []identity.AgentIdentity{} |
| 605 | } |
| 606 | |
| 607 | w.Header().Set("Content-Type", "application/json") |
| 608 | writeJSON(w, map[string][]identity.AgentIdentity{"agents": agents}) |
| 609 | } |
| 610 | |
| 611 | // HandleDeleteAgent deletes an agent owned by the authenticated user. |
| 612 | func (ua *UserAuth) HandleDeleteAgent(w http.ResponseWriter, r *http.Request) { |
nothing calls this directly
no test coverage detected