!55 docs: 修正工程管理文档中的认证方式说明

Merge pull request !55 from 何朝晖/fix/auth
This commit is contained in:
2026-05-25 08:59:39 +00:00
committed by Gitee
2 changed files with 19 additions and 2 deletions
+18 -1
View File
@@ -2,6 +2,7 @@ package mildware
import (
"net/http"
"strconv"
"strings"
"gen2d/internal/logger"
@@ -45,7 +46,23 @@ func AuthMiddleware(jwtSecret string) gin.HandlerFunc {
}
if sub, ok := claims["sub"]; ok {
c.Set("userID", sub)
var userID uint
switch v := sub.(type) {
case float64:
userID = uint(v)
case int:
userID = uint(v)
case int64:
userID = uint(v)
case uint:
userID = v
case string:
num, err := strconv.ParseUint(v, 10, 64)
if err == nil {
userID = uint(num)
}
}
c.Set("userID", userID)
}
c.Next()
+1 -1
View File
@@ -213,7 +213,7 @@ POST /api/v1/prompt/optimize
## 工程管理
需认证。以下接口均需通过 Cookie 携带 Token,工程归属于当前登录用户。
需认证。以下接口均需通过 `Authorization: Bearer <token>` 请求头携带 Token,工程归属于当前登录用户。
| 状态 | 方法 | 路径 | 说明 |
|------|------|------|------|