From ec637401db1747a300b3cab2d54e0955cc10b52e Mon Sep 17 00:00:00 2001 From: gearnode Date: Fri, 14 Mar 2025 10:10:17 +0100 Subject: [PATCH] Align token datetime Signed-off-by: gearnode --- pkg/statelesstoken/token.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/pkg/statelesstoken/token.go b/pkg/statelesstoken/token.go index ebc46cc5d..3d60fd727 100644 --- a/pkg/statelesstoken/token.go +++ b/pkg/statelesstoken/token.go @@ -68,9 +68,11 @@ func (e ErrExpiredToken) Error() string { // NewToken creates a new token with the specified type, data, and expiration time func NewToken[T any](secret string, tokenType string, expirationTime time.Duration, data T) (string, error) { + now := time.Now() + payload := Payload[T]{ - ExpiresAt: time.Now().Add(expirationTime), - IssuedAt: time.Now(), + ExpiresAt: now.Add(expirationTime), + IssuedAt: now, Type: tokenType, Data: data, }