This commit is contained in:
hero920103 committed 2026-10-19 01:13:17 +08:00
1 parent 5718a00e31
commit 1850ac640e
226 files changed
+37772 -12071

No files matched your search

+4 -16
View File
@@ -6,6 +6,7 @@ import (
"time"
"server/models"
"server/pkg/identity"
"server/pkg/jwtutil"
"server/services"
@@ -33,23 +34,10 @@ func resolveUserName(claims *jwtutil.Claims) string {
// related_type 约定:1=线索 2=商机 3=项目
// pipelineClaims 解析租户端后台 JWT。
// CRM 管线接口只挂在 /backend/** 下(平台端无对应路由、平台前端也不调),
// 此前顺带放行 platform 等于让平台令牌能读写租户的商机与投标数据。
func pipelineClaims(c *beego.Controller) (*jwtutil.Claims, error) {
auth := c.Ctx.Request.Header.Get("Authorization")
if auth == "" {
return nil, fmt.Errorf("未登录")
}
parts := strings.SplitN(auth, " ", 2)
if len(parts) != 2 || parts[0] != "Bearer" {
return nil, fmt.Errorf("认证信息格式错误")
}
claims, err := jwtutil.ParseToken(parts[1])
if err != nil {
return nil, fmt.Errorf("无效的token")
}
if claims.UserType != "backend" && claims.UserType != "platform" {
return nil, fmt.Errorf("无权访问")
}
return claims, nil
return identity.Claims(c.Ctx.Request.Header.Get("Authorization"), identity.EndBackend)
}
// pipelineOk 统一成功响应。