改造成api
This commit is contained in:
@@ -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
|
||||
}
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user