fix(api): fail closed when status update cannot set user role

Return the UpdateUserRole error instead of silently continuing when an
admin approves a user with an explicit role_id.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
weichen
2026-09-13 11:37:03 +00:00
co-authored by Cursor
parent f189ce9ff9
commit d421fba472
+4 -1
View File
@@ -294,7 +294,10 @@ func (s *Server) handleAdminUpdateStatus(w http.ResponseWriter, r *http.Request)
}
if req.RoleID != "" {
_, _ = s.authSvc.UpdateUserRole(r.Context(), targetID, req.RoleID, req.Position)
if _, roleErr := s.authSvc.UpdateUserRole(r.Context(), targetID, req.RoleID, req.Position); roleErr != nil {
http.Error(w, roleErr.Error(), http.StatusBadRequest)
return
}
}
updated, err := s.authSvc.UpdateUserStatus(r.Context(), targetID, req.Status)