diff --git a/utils/basic/request_parse.go b/utils/basic/request_parse.go index 86c0ebfd..42879699 100644 --- a/utils/basic/request_parse.go +++ b/utils/basic/request_parse.go @@ -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) //获取缓存的用户状态