New file |
| | |
| | | package middleware |
| | | |
| | | import ( |
| | | "github.com/gin-gonic/gin" |
| | | "wms/pkg/contextx" |
| | | "wms/pkg/ecode" |
| | | "wms/request" |
| | | ) |
| | | |
| | | func VerifyResetPwd() gin.HandlerFunc { |
| | | return func(c *gin.Context) { |
| | | ctx := new(contextx.Context).SetCtx(c) |
| | | params, ok := c.Get("claims") |
| | | if !ok { |
| | | c.Abort() |
| | | return |
| | | } |
| | | claims := params.(*request.CustomClaims) |
| | | if !claims.ModifiedPwd { |
| | | ctx.Fail(ecode.ResetPwd) |
| | | c.Abort() |
| | | return |
| | | } |
| | | } |
| | | } |
| | |
| | | JWTEmpty = 2013 // JWT为空 |
| | | JWTExpire = 2014 // JWT过期 |
| | | JWTParseErr = 2015 // JWT解析失败 |
| | | ResetPwd = 2036 //账号设置密码 |
| | | ) |
| | |
| | | } |
| | | |
| | | type BaseClaims struct { |
| | | UserId string |
| | | Username string |
| | | ParentId string |
| | | UserType constvar.UserType |
| | | UserId string |
| | | Username string |
| | | ParentId string |
| | | UserType constvar.UserType |
| | | ModifiedPwd bool |
| | | } |
| | |
| | | |
| | | urlPrefix := "/api-wms/v1" |
| | | r.Use(middleware.JWTAuth()) |
| | | r.Use(middleware.VerifyResetPwd()) |
| | | |
| | | // 组织管理 |
| | | departmentController := new(controllers.DepartmentController) |