zhangqian
2024-03-25 63d76f26a0e8852a321218a2d38984e3951c0531
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
package middleware
 
import (
    "aps_crm/model/request"
    "aps_crm/pkg/contextx"
    "aps_crm/pkg/ecode"
    "github.com/gin-gonic/gin"
)
 
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 == nil { //兼容没有ModifiedPwd值的token
            ctx.Fail(ecode.JWTExpire)
            c.Abort()
            return
        }
 
        if !*claims.ModifiedPwd {
            ctx.Fail(ecode.ResetPwd)
            c.Abort()
            return
        }
    }
}