fix auth middleware and statistics issues

This commit is contained in:
Fran Jurmanović
2025-06-26 01:56:49 +02:00
parent 74df36cd0d
commit 7fdda06dba
9 changed files with 37 additions and 42 deletions

View File

@@ -6,7 +6,6 @@ import (
"time"
"github.com/golang-jwt/jwt/v4"
"github.com/google/uuid"
)
// SecretKey is the secret key for signing the JWT.
@@ -16,7 +15,7 @@ var SecretKey = []byte("your-secret-key")
// Claims represents the JWT claims.
type Claims struct {
UserID uuid.UUID `json:"user_id"`
UserID string `json:"user_id"`
jwt.RegisteredClaims
}
@@ -24,7 +23,7 @@ type Claims struct {
func GenerateToken(user *model.User) (string, error) {
expirationTime := time.Now().Add(24 * time.Hour)
claims := &Claims{
UserID: user.ID,
UserID: user.ID.String(),
RegisteredClaims: jwt.RegisteredClaims{
ExpiresAt: jwt.NewNumericDate(expirationTime),
},