Changeset 0.8.6 (#49)

This commit is contained in:
2026-02-22 16:52:19 +00:00
parent 633421708f
commit 15be26c516
17 changed files with 870 additions and 152 deletions

View File

@@ -128,7 +128,7 @@ func (h *PresetHandler) CreateUserPreset(c *gin.Context) {
var count int
err := database.DB.QueryRow(`
SELECT COUNT(*) FROM api_configs
WHERE id = $1 AND (user_id = $2 OR is_global = true OR user_id IS NULL) AND is_active = true
WHERE id = $1 AND (user_id = $2 OR is_global = true) AND is_active = true AND team_id IS NULL
`, *req.APIConfigID, userID).Scan(&count)
if err != nil || count == 0 {
c.JSON(http.StatusBadRequest, gin.H{"error": "invalid or inaccessible API config"})
@@ -342,7 +342,7 @@ func (h *PresetHandler) CreateAdminPreset(c *gin.Context) {
var count int
err := database.DB.QueryRow(`
SELECT COUNT(*) FROM api_configs
WHERE id = $1 AND (is_global = true OR user_id IS NULL) AND is_active = true
WHERE id = $1 AND is_global = true AND is_active = true AND team_id IS NULL
`, *req.APIConfigID).Scan(&count)
if err != nil || count == 0 {
c.JSON(http.StatusBadRequest, gin.H{"error": "global presets must use a global API config"})