feat: CR login, register, subscribe

This commit is contained in:
ericprd
2025-02-24 16:48:20 +08:00
parent ae5b2cb975
commit cb3d06fa02
48 changed files with 1027 additions and 59 deletions
+12 -13
View File
@@ -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)