Align token datetime

Signed-off-by: gearnode <bryan@frimin.fr>
This commit is contained in:
gearnode
2025-03-14 10:10:17 +01:00
parent 51f2bcb6ef
commit ec637401db

View File

@@ -68,9 +68,11 @@ func (e ErrExpiredToken) Error() string {
// NewToken creates a new token with the specified type, data, and expiration time // 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) { func NewToken[T any](secret string, tokenType string, expirationTime time.Duration, data T) (string, error) {
now := time.Now()
payload := Payload[T]{ payload := Payload[T]{
ExpiresAt: time.Now().Add(expirationTime), ExpiresAt: now.Add(expirationTime),
IssuedAt: time.Now(), IssuedAt: now,
Type: tokenType, Type: tokenType,
Data: data, Data: data,
} }