diff --git a/utils/basic/request_parse.go b/utils/basic/request_parse.go index 31d75674..8b99eab7 100644 --- a/utils/basic/request_parse.go +++ b/utils/basic/request_parse.go @@ -3,6 +3,7 @@ package basic import ( "errors" "log" + "strconv" "fusenapi/shared" "fusenapi/utils/auth" @@ -56,16 +57,21 @@ func RequestParse(w http.ResponseWriter, r *http.Request, svcCtx any, LogicReque var userinfo *auth.UserInfo var err error // log.Println(io.ReadAll(r.Body)) - token, info, err := auth.ParseJwtTokenHeader[auth.UserInfo](r) //解析Token头, 和payload信息 + token := r.Header.Get("Authorization") + userId, err := strconv.ParseInt(token, 10, 63) if err != nil { - logx.Error(err) - return nil, err - } - - if token == "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJleHAiOjE3MjQyOTM0NjIsImd1ZXN0X2lkIjozNiwiaWF0IjozMTUzNjAwMCwidXNlcl9pZCI6MH0.T7PuRSrinlJu7ZZ1DVqUJLWXhY_6R1lXiUHaNdw35hU" { - userinfo = info + 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 + } + if info != nil { if info.IsUser() {