1、action中各动作添加数据权限

2、修改jwt中key为常量
This commit is contained in:
linwenxiang committed 2020-09-03 10:49:31 +08:00
1 parent d3622c93fc
commit 4b8c372038
8 files changed
+54 -16

No files matched your search

+4 -2
View File
@@ -12,6 +12,8 @@ import (
"time"
)
const JwtPayloadKey = "JWT_PAYLOAD"
type MapClaims map[string]interface{}
// GinJWTMiddleware provides a Json-Web-Token authentication implementation. On failure, a 401 HTTP response
@@ -400,7 +402,7 @@ func (mw *GinJWTMiddleware) middlewareImpl(c *gin.Context) {
return
}
c.Set("JWT_PAYLOAD", claims)
c.Set(JwtPayloadKey, claims)
identity := mw.IdentityHandler(c)
if identity != nil {
@@ -716,7 +718,7 @@ func (mw *GinJWTMiddleware) unauthorized(c *gin.Context, code int, message strin
// ExtractClaims help to extract the JWT claims
func ExtractClaims(c *gin.Context) MapClaims {
claims, exists := c.Get("JWT_PAYLOAD")
claims, exists := c.Get(JwtPayloadKey)
if !exists {
return make(MapClaims)
}