mirror of
https://github.com/openimsdk/open-im-server.git
synced 2025-04-06 04:15:46 +08:00
24 lines
523 B
Go
24 lines
523 B
Go
package middleware
|
|
|
|
import (
|
|
"Open_IM/pkg/common/constant"
|
|
"Open_IM/pkg/common/http"
|
|
"Open_IM/pkg/common/log"
|
|
"Open_IM/pkg/common/token_verify"
|
|
"fmt"
|
|
"github.com/gin-gonic/gin"
|
|
)
|
|
|
|
func JWTAuth() gin.HandlerFunc {
|
|
return func(c *gin.Context) {
|
|
ok, token := token_verify.GetUserIDFromToken(c.Request.Header.Get("token"))
|
|
fmt.Println(token)
|
|
if !ok {
|
|
log.NewError("","GetUserIDFromToken false ", c.Request.Header.Get("token"))
|
|
c.Abort()
|
|
http.RespHttp200(c, constant.ErrParseToken, nil)
|
|
return
|
|
}
|
|
}
|
|
}
|