改造成api

This commit is contained in:
2025-07-02 14:51:23 +08:00
parent c8a81d0f49
commit 39e91e85ba
27 changed files with 665 additions and 519 deletions

View File

@@ -26,6 +26,7 @@ var publicRoutes = map[string]bool{
"/upload/file": true,
"/upload/multi_files": true,
"/logout": true,
"/user_info": true,
}
// 分片缓存配置
@@ -147,13 +148,17 @@ func Authorize(
return
}
setUser(ctx, payload)
ctx.Next()
return
// 用户校验完毕, 开始校验权限
path := ctx.Request.URL.Path
// 公共路由放行
if publicRoutes[path] {
ctx.Set(authorizationPayloadKey, payload)
setUser(ctx, payload)
ctx.Next()
return
}

View File

@@ -20,7 +20,7 @@ func setUser(ctx *gin.Context, payload *token.Payload) {
// GetUser returns the user from the context.
func GetUser(ctx *gin.Context) *token.Payload {
value, exists := ctx.Get(authorizationHeaderKey)
value, exists := ctx.Get(authorizationPayloadKey)
if !exists {
return nil
}