Changeset 0.9.2 (#52)
This commit is contained in:
@@ -6,6 +6,7 @@ import (
|
||||
"log"
|
||||
"net/http"
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
"golang.org/x/crypto/bcrypt"
|
||||
@@ -71,8 +72,8 @@ func (h *AdminHandler) CreateUser(c *gin.Context) {
|
||||
}
|
||||
|
||||
user := &models.User{
|
||||
Username: req.Username,
|
||||
Email: req.Email,
|
||||
Username: strings.ToLower(req.Username),
|
||||
Email: strings.ToLower(req.Email),
|
||||
PasswordHash: string(hash),
|
||||
Role: role,
|
||||
IsActive: true,
|
||||
@@ -243,7 +244,20 @@ func (h *AdminHandler) ListGlobalConfigs(c *gin.Context) {
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"error": "failed to list configs"})
|
||||
return
|
||||
}
|
||||
c.JSON(http.StatusOK, gin.H{"configs": cfgs})
|
||||
|
||||
// Redact API keys but expose has_key flag for UI
|
||||
type configWithKey struct {
|
||||
models.ProviderConfig
|
||||
HasKey bool `json:"has_key"`
|
||||
}
|
||||
out := make([]configWithKey, len(cfgs))
|
||||
for i, cfg := range cfgs {
|
||||
out[i] = configWithKey{
|
||||
ProviderConfig: cfg,
|
||||
HasKey: cfg.APIKeyEnc != "",
|
||||
}
|
||||
}
|
||||
c.JSON(http.StatusOK, gin.H{"configs": out})
|
||||
}
|
||||
|
||||
func (h *AdminHandler) CreateGlobalConfig(c *gin.Context) {
|
||||
@@ -293,7 +307,22 @@ func (h *AdminHandler) CreateGlobalConfig(c *gin.Context) {
|
||||
}
|
||||
|
||||
h.auditLog(c, "provider.create", "provider_config", cfg.ID, gin.H{"name": cfg.Name, "provider": cfg.Provider})
|
||||
c.JSON(http.StatusCreated, cfg)
|
||||
c.JSON(http.StatusCreated, gin.H{
|
||||
"id": cfg.ID,
|
||||
"scope": cfg.Scope,
|
||||
"name": cfg.Name,
|
||||
"provider": cfg.Provider,
|
||||
"endpoint": cfg.Endpoint,
|
||||
"model_default": cfg.ModelDefault,
|
||||
"config": cfg.Config,
|
||||
"headers": cfg.Headers,
|
||||
"settings": cfg.Settings,
|
||||
"is_active": cfg.IsActive,
|
||||
"is_private": cfg.IsPrivate,
|
||||
"has_key": cfg.APIKeyEnc != "",
|
||||
"created_at": cfg.CreatedAt,
|
||||
"updated_at": cfg.UpdatedAt,
|
||||
})
|
||||
}
|
||||
|
||||
func (h *AdminHandler) UpdateGlobalConfig(c *gin.Context) {
|
||||
|
||||
Reference in New Issue
Block a user