修改jwt拦截处理,添加错误问题
This commit is contained in:
parent
b1205306e4
commit
3c9b36cc07
20
main.go
20
main.go
|
|
@ -111,17 +111,17 @@ func JWTAuthMiddleware() gin.HandlerFunc {
|
||||||
if tokenString == "" {
|
if tokenString == "" {
|
||||||
tokenString = c.Query("token")
|
tokenString = c.Query("token")
|
||||||
}
|
}
|
||||||
//for k, _ := range proto.Url_map {
|
for k, _ := range proto.Url_map {
|
||||||
// if strings.Contains(c.Request.URL.Path, k) {
|
if strings.Contains(c.Request.URL.Path, k) {
|
||||||
// log.Println("need not check token:", c.Request.URL.Path)
|
log.Println("need not check token:", c.Request.URL.Path)
|
||||||
// c.Next()
|
c.Next()
|
||||||
// return
|
return
|
||||||
// }
|
}
|
||||||
//}
|
|
||||||
if proto.Url_map[c.Request.URL.Path] == true { //查看是否在不需要token的url中
|
|
||||||
c.Next()
|
|
||||||
return
|
|
||||||
}
|
}
|
||||||
|
//if proto.Url_map[c.Request.URL.Path] == true { //查看是否在不需要token的url中
|
||||||
|
// c.Next()
|
||||||
|
// return
|
||||||
|
//}
|
||||||
if tokenString == "" {
|
if tokenString == "" {
|
||||||
c.AbortWithStatusJSON(http.StatusOK, gin.H{"message": "unauthorized", "error": "token is empty", "code": proto.TokenIsNull})
|
c.AbortWithStatusJSON(http.StatusOK, gin.H{"message": "unauthorized", "error": "token is empty", "code": proto.TokenIsNull})
|
||||||
return
|
return
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue