@@ -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,
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user