From 39b652ce58bc8c750f8d5f55f134d18e6b72f918 Mon Sep 17 00:00:00 2001 From: eson <9673575+githubcontent@user.noreply.gitee.com> Date: Mon, 28 Aug 2023 18:38:34 +0800 Subject: [PATCH] good --- utils/auth/user.go | 11 +++++------ utils/basic/request_parse_test.go | 5 ++--- 2 files changed, 7 insertions(+), 9 deletions(-) diff --git a/utils/auth/user.go b/utils/auth/user.go index aaa7c357..8869ebbd 100644 --- a/utils/auth/user.go +++ b/utils/auth/user.go @@ -134,12 +134,11 @@ func GenerateJwtTokenUint64(AccessSecret uint64, accessExpire, nowSec int64, use claims["exp"] = nowSec + accessExpire claims["iat"] = nowSec - if userid == 0 && guestid == 0 { - err := errors.New("userid and guestid cannot be 0 at the same time") - logx.Error(err) - return "", err - - } + // if userid == 0 && guestid == 0 { + // err := errors.New("userid and guestid cannot be 0 at the same time") + // logx.Error(err) + // return "", err + // } claims["user_id"] = userid claims["guest_id"] = guestid diff --git a/utils/basic/request_parse_test.go b/utils/basic/request_parse_test.go index e5df9ca4..05a240b3 100644 --- a/utils/basic/request_parse_test.go +++ b/utils/basic/request_parse_test.go @@ -18,12 +18,11 @@ func TestHash(t *testing.T) { h := sha256.New() h.Write([]byte(a)) s := "5JlPincPavgw0X/Fmj15xLId5vOEtdarc6hR1XlBx80=" - - log.Println(auth.GenerateJwtTokenUint64(auth.StringToHash(s), 421231233, time.Now().UTC().Unix(), 39, 0)) + log.Println(auth.GenerateJwtTokenUint64(auth.StringToHash(s), 999999999999999, time.Now().UTC().Unix(), 0, 0)) key := auth.StringToHash(s) log.Println(key) // log.Println(auth.GenerateJwtTokenUint64(auth.StringToHash(s), 400000000, time.Now().UTC().Unix(), 39, 0)) - authkey := "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJleHAiOjIwOTMxOTIyMjYsImd1ZXN0X2lkIjowLCJpYXQiOjE2OTMxOTIyMjYsInVzZXJfaWQiOjM5fQ.DrvtD7gKB0gz1rAOAQHSnyBK3exTFqoLlacpZiadpB4" + authkey := "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJleHAiOjEwMDAwMDAwMDE2OTMyMTYxNDMsImd1ZXN0X2lkIjowLCJpYXQiOjE2OTMyMTYxNDQsInVzZXJfaWQiOjB9.KnesyIk9hNHlXPRkvqNmI7pf-icxmL8VB56zUm6ajxE" log.Println(authkey) log.Println(auth.TParseJwtTokenHeader[auth.UserInfo](authkey)) log.Println(auth.ParseJwtTokenUint64Secret(authkey, key))