This commit is contained in:
wangchuxiao
2022-02-12 17:13:31 +08:00
parent 6de61cb214
commit 52579c5fab
23 changed files with 618 additions and 111 deletions
+13 -1
View File
@@ -1,11 +1,23 @@
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
}
}
}