fix: lint issues

This commit is contained in:
yanghao05
2023-03-09 10:23:23 +08:00
parent 8d1bd191df
commit 5943b9e1d5
17 changed files with 88 additions and 78 deletions

View File

@@ -50,11 +50,9 @@ func CorsByRules(config *config.Config) gin.HandlerFunc {
// 严格白名单模式且未通过检查,直接拒绝处理请求
if whitelist == nil && config.Http.Cors.Mode == "strict-whitelist" && !(c.Request.Method == "GET" && c.Request.URL.Path == "/health") {
c.AbortWithStatus(http.StatusForbidden)
} else {
} else if c.Request.Method == http.MethodOptions {
// 非严格白名单模式,无论是否通过检查均放行所有 OPTIONS 方法
if c.Request.Method == http.MethodOptions {
c.AbortWithStatus(http.StatusNoContent)
}
c.AbortWithStatus(http.StatusNoContent)
}
// 处理请求

View File

@@ -29,7 +29,7 @@ func JWTAuth(j *jwt.JWT) gin.HandlerFunc {
// 已登录用户被管理员禁用 需要使该用户的jwt失效 此处比较消耗性能 如果需要 请自行打开
// 用户被删除的逻辑 需要优化 此处比较消耗性能 如果需要 请自行打开
//if user, err := userService.FindUserByUuid(claims.UUID.String()); err != nil || user.Enable == 2 {
// if user, err := userService.FindUserByUuid(claims.UUID.String()); err != nil || user.Enable == 2 {
// _ = jwtService.JsonInBlacklist(system.JwtBlacklist{Jwt: token})
// response.FailWithDetailed(gin.H{"reload": true}, err.Error(), c)
// c.Abort()

View File

@@ -27,7 +27,7 @@ func CheckPermission(config *config.Config, rbac rbac.IRbac) gin.HandlerFunc {
}
claims := claimsCtx.(jwt.Claims)
//获取请求的PATH
// 获取请求的PATH
path := c.Request.URL.Path
// 获取请求方法