Set the token activity time to five minutes ago

This commit is contained in:
skiffer-git 2022-08-15 15:40:36 +08:00
parent 652d560a21
commit 073b6d200a
2 changed files with 3 additions and 3 deletions

View File

@ -524,7 +524,7 @@ func init() {
if err != nil {
bytes, err = ioutil.ReadFile(filepath.Join(Root, "config", "config.yaml"))
if err != nil {
panic(err.Error())
panic(err.Error() + " config: " + filepath.Join(cfgName, "config", "config.yaml"))
}
} else {
Root = cfgName
@ -541,5 +541,4 @@ func init() {
panic(err.Error())
}
}
}

View File

@ -28,13 +28,14 @@ type Claims struct {
func BuildClaims(uid, platform string, ttl int64) Claims {
now := time.Now()
before := now.Add(-time.Minute * 5)
return Claims{
UID: uid,
Platform: platform,
RegisteredClaims: jwt.RegisteredClaims{
ExpiresAt: jwt.NewNumericDate(now.Add(time.Duration(ttl*24) * time.Hour)), //Expiration time
IssuedAt: jwt.NewNumericDate(now), //Issuing time
NotBefore: jwt.NewNumericDate(now), //Begin Effective time
NotBefore: jwt.NewNumericDate(before), //Begin Effective time
}}
}