initial crm server

This commit is contained in:
zchengo
2022-11-28 16:38:30 +08:00
parent 61122aef6a
commit af7cd0c44c
36 changed files with 2615 additions and 0 deletions
+27
View File
@@ -0,0 +1,27 @@
package middleware
import (
"crm/response"
"crm/service"
"github.com/gin-gonic/gin"
)
// JwtAuth JWT认证中间件
func JwtAuth() gin.HandlerFunc {
return func(c *gin.Context) {
token := c.Request.Header.Get("token")
if token == "" {
response.Result(response.ErrCodeNoLogin, nil, c)
c.Abort()
return
}
user := &service.UserService{}
if err := user.VerifyToken(token); err != nil {
response.Result(response.ErrCodeTokenExpire, nil, c)
c.Abort()
return
}
c.Next()
}
}