feat: CR login, register, subscribe
This commit is contained in:
@@ -3,7 +3,6 @@ package utils
|
||||
import (
|
||||
"time"
|
||||
|
||||
jwtclaimenum "github.com/ardeman/project-legalgo-go/internal/enums/jwt"
|
||||
timeutils "github.com/ardeman/project-legalgo-go/internal/utilities/time_utils"
|
||||
"github.com/golang-jwt/jwt/v5"
|
||||
)
|
||||
@@ -12,23 +11,23 @@ var jwtSecret = []byte("secret jwt key") // TODO: change later from env
|
||||
|
||||
type ClaimOption func(options jwt.MapClaims)
|
||||
|
||||
func GenerateToken(options ...ClaimOption) (string, error) {
|
||||
now := timeutils.Now()
|
||||
// func GenerateToken(options ...ClaimOption) (string, error) {
|
||||
// now := timeutils.Now()
|
||||
|
||||
claims := jwt.MapClaims{
|
||||
string(jwtclaimenum.ISSUED_AT): now.Unix(),
|
||||
}
|
||||
// claims := jwt.MapClaims{
|
||||
// string(jwtclaimenum.ISSUED_AT): now.Unix(),
|
||||
// }
|
||||
|
||||
for _, o := range options {
|
||||
o(claims)
|
||||
}
|
||||
// for _, o := range options {
|
||||
// o(claims)
|
||||
// }
|
||||
|
||||
token := jwt.NewWithClaims(jwt.SigningMethodHS256, claims)
|
||||
// token := jwt.NewWithClaims(jwt.SigningMethodHS256, claims)
|
||||
|
||||
return token.SignedString(jwtSecret)
|
||||
}
|
||||
// return token.SignedString(jwtSecret)
|
||||
// }
|
||||
|
||||
func GenerateToken2(email string) (string, error) {
|
||||
func GenerateToken(email string) (string, error) {
|
||||
now := timeutils.Now()
|
||||
token := jwt.New(jwt.SigningMethodHS256)
|
||||
claims := token.Claims.(jwt.MapClaims)
|
||||
|
||||
Reference in New Issue
Block a user