| | |
| | | PrivateGroup.GET("previewContract", conApi.PreviewContract) // 预览Contract |
| | | PrivateGroup.GET("downloadContract", conApi.DownloadContract) // 下载Contract |
| | | |
| | | PrivateGroup.Use(middleware.JWTAuth()) |
| | | PrivateGroup.Use(middleware.JWTAuth()).Use(middleware.VerifyResetPwd()) |
| | | { |
| | | systemRouter.InitSystemRouter(PrivateGroup) // system相关路由 |
| | | //exampleRouter.InitFileUploadAndDownloadRouter(PrivateGroup) // 文件上传下载功能路由 |
New file |
| | |
| | | package middleware |
| | | |
| | | import ( |
| | | "github.com/gin-gonic/gin" |
| | | "srm/pkg/contextx" |
| | | "srm/pkg/ecode" |
| | | "srm/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 |
| | | } |