| | |
| | | |
| | | import ( |
| | | "github.com/gin-gonic/gin" |
| | | "wms/conf" |
| | | "wms/pkg/contextx" |
| | | "wms/pkg/ecode" |
| | | "wms/request" |
| | |
| | | |
| | | func VerifyResetPwd() gin.HandlerFunc { |
| | | return func(c *gin.Context) { |
| | | if conf.WebConf.Env.IsDev() { |
| | | c.Next() |
| | | return |
| | | } |
| | | ctx := new(contextx.Context).SetCtx(c) |
| | | params, ok := c.Get("claims") |
| | | if !ok { |
| | | c.Abort() |
| | | c.Next() |
| | | return |
| | | } |
| | | claims := params.(*request.CustomClaims) |
| | | if !claims.ModifiedPwd { |
| | | if claims.ModifiedPwd == nil { //兼容没有ModifiedPwd值的token |
| | | ctx.Fail(ecode.JWTExpire) |
| | | c.Abort() |
| | | return |
| | | } |
| | | |
| | | if !*claims.ModifiedPwd { |
| | | ctx.Fail(ecode.ResetPwd) |
| | | c.Abort() |
| | | return |