Skip to content

Commit

Permalink
fix: consistent timestamp for issuedAt and expiredAt of the token
Browse files Browse the repository at this point in the history
  • Loading branch information
richzw committed Jun 3, 2024
1 parent e71bbdb commit 703406d
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions token.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,11 +79,12 @@ func (t *Token) Generate() error {
}
t.AuthKey = key

issuedAt := time.Now().Unix()
now := time.Now()
issuedAt := now.Unix()
if t.IssuedAtFunc != nil {
issuedAt = t.IssuedAtFunc()
}
expiredAt := time.Now().Add(time.Duration(1) * time.Hour).Unix()
expiredAt := now.Add(time.Duration(1) * time.Hour).Unix()
if t.ExpiredAtFunc != nil {
expiredAt = t.ExpiredAtFunc()
}
Expand Down

0 comments on commit 703406d

Please sign in to comment.