This commit is contained in:
eson 2023-08-28 12:23:12 +08:00
parent d139ea2cee
commit aa5b90e0d4

View File

@ -60,19 +60,19 @@ func ParseJwtToken(r *http.Request, svcCtx any) (*auth.UserInfo, error) {
// log.Println(io.ReadAll(r.Body))
token := r.Header.Get("Authorization")
userId, err := strconv.ParseInt(token, 10, 64)
if err != nil {
if err == nil {
userinfo = &auth.UserInfo{
UserId: userId,
}
} else {
var secret uint64 = 0
token, info, err := auth.ParseJwtTokenHeader[auth.UserInfo](r) //解析Token头, 和payload信息
if err != nil {
logx.Error(err)
return nil, err
}
log.Println("!= 0", info)
if info != nil {
if info.IsUser() {
// us, err := state.GetUserState(info.UserId) //获取缓存的用户状态