测试
This commit is contained in:
parent
e780709629
commit
7a02b3242e
|
@ -2,6 +2,7 @@ package basic
|
|||
|
||||
import (
|
||||
"errors"
|
||||
"log"
|
||||
|
||||
"fusenapi/shared"
|
||||
"fusenapi/utils/auth"
|
||||
|
@ -89,6 +90,7 @@ func RequestParse(w http.ResponseWriter, r *http.Request, svcCtx any, LogicReque
|
|||
claims, err := auth.ParseJwtTokenUint64Secret(token, secret)
|
||||
// 如果解析JWT token出错,则返回未授权的JSON响应并记录错误消息
|
||||
if err != nil {
|
||||
log.Println(token)
|
||||
httpx.OkJsonCtx(r.Context(), w, &Response{
|
||||
Code: 401, // 返回401状态码,表示未授权
|
||||
Message: "unauthorized", // 返回未授权信息
|
||||
|
|
|
@ -7,6 +7,6 @@ import (
|
|||
)
|
||||
|
||||
func TestRequestParse(t *testing.T) {
|
||||
a, us, err := auth.TParseJwtTokenHeader[auth.UserInfo]("eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJleHAiOjE3MjQ0NzE1MzUsImd1ZXN0X2lkIjo0OCwiaWF0IjozMTUzNjAwMCwidXNlcl9pZCI6MH0.jsIpl9CeQdGHRERPByVtMlPLxaxzBaorJsmtfQqbgVc")
|
||||
a, us, err := auth.TParseJwtTokenHeader[auth.UserInfo]("saTGjruwq7SG4vnQVEo3vsZvbfhzx8zZ3zWA+8nWVdid5tssnYQNECiP+pYCK6YhZ+LRH8m7f7JXrgyqtpYQMOhVOcNWTYAClk0Jnft6+QIPegzY9+v4k7eVMiWf5c/x")
|
||||
log.Println(a, us, err)
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user