good
This commit is contained in:
parent
bc057ed73d
commit
39b652ce58
|
@ -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
|
||||
|
||||
|
|
|
@ -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))
|
||||
|
|
Loading…
Reference in New Issue
Block a user