This commit is contained in:
Salim Amine Bou Aram
2024-10-31 20:32:54 +01:00
parent 5628125ad3
commit ef2768c431
26 changed files with 706 additions and 379 deletions

View File

@@ -1,8 +1,9 @@
package models
import (
"github.com/golang-jwt/jwt/v4"
"time"
"github.com/golang-jwt/jwt/v4"
)
type Account struct {
@@ -36,11 +37,11 @@ type UserClaims struct {
}
func (account Account) CreateToken(ttl time.Duration, key string) (token string, err error) {
expires_at := jwt.NewNumericDate(time.Now().Add(ttl))
expiresAt := jwt.NewNumericDate(time.Now().Add(ttl))
claims := UserClaims{
RegisteredClaims: jwt.RegisteredClaims{
Subject: account.ID,
ExpiresAt: expires_at,
ExpiresAt: expiresAt,
},
}