|
|
@ -3,7 +3,6 @@ package middleware
|
|
|
|
import (
|
|
|
|
import (
|
|
|
|
"github.com/gin-gonic/gin"
|
|
|
|
"github.com/gin-gonic/gin"
|
|
|
|
"github.com/taoshihan1991/imaptool/tools"
|
|
|
|
"github.com/taoshihan1991/imaptool/tools"
|
|
|
|
"log"
|
|
|
|
|
|
|
|
"time"
|
|
|
|
"time"
|
|
|
|
)
|
|
|
|
)
|
|
|
|
func JwtPageMiddleware(c *gin.Context){
|
|
|
|
func JwtPageMiddleware(c *gin.Context){
|
|
|
@ -18,13 +17,13 @@ func JwtPageMiddleware(c *gin.Context){
|
|
|
|
func JwtApiMiddleware(c *gin.Context){
|
|
|
|
func JwtApiMiddleware(c *gin.Context){
|
|
|
|
token := c.GetHeader("token")
|
|
|
|
token := c.GetHeader("token")
|
|
|
|
userinfo := tools.ParseToken(token)
|
|
|
|
userinfo := tools.ParseToken(token)
|
|
|
|
log.Println(userinfo)
|
|
|
|
if userinfo == nil||userinfo["name"]==nil||userinfo["create_time"]==nil {
|
|
|
|
if userinfo == nil||userinfo["name"]==nil {
|
|
|
|
|
|
|
|
c.JSON(200, gin.H{
|
|
|
|
c.JSON(200, gin.H{
|
|
|
|
"code": 400,
|
|
|
|
"code": 400,
|
|
|
|
"msg": "验证失败",
|
|
|
|
"msg": "验证失败",
|
|
|
|
})
|
|
|
|
})
|
|
|
|
c.Abort()
|
|
|
|
c.Abort()
|
|
|
|
|
|
|
|
return
|
|
|
|
}
|
|
|
|
}
|
|
|
|
createTime:=int64(userinfo["create_time"].(float64))
|
|
|
|
createTime:=int64(userinfo["create_time"].(float64))
|
|
|
|
var expire int64=2*60*60
|
|
|
|
var expire int64=2*60*60
|
|
|
@ -40,5 +39,6 @@ func JwtApiMiddleware(c *gin.Context){
|
|
|
|
if userinfo["type"]=="kefu"{
|
|
|
|
if userinfo["type"]=="kefu"{
|
|
|
|
c.Set("kefu_id",userinfo["kefu_id"])
|
|
|
|
c.Set("kefu_id",userinfo["kefu_id"])
|
|
|
|
c.Set("kefu_name",userinfo["name"])
|
|
|
|
c.Set("kefu_name",userinfo["name"])
|
|
|
|
|
|
|
|
c.Set("role_id",userinfo["role_id"])
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|