add cache for groups and clients, http sending message remains to be add

This commit is contained in:
2026-03-15 14:15:24 +01:00
parent 76fbb8b970
commit c97b21a39e
7 changed files with 166 additions and 89 deletions
+4 -3
View File
@@ -7,7 +7,6 @@ import (
"time"
"github.com/golang-jwt/jwt/v5"
_ "github.com/golang-jwt/jwt/v5"
)
var secretKey = []byte("replace-with-env-variable")
@@ -22,7 +21,7 @@ func GetToken(user *User) (string, error) {
token := jwt.NewWithClaims(jwt.SigningMethodHS256,
UserClaims{
Name: user.Name,
Color: user.Color,
Color: string(user.Color[:]),
RegisteredClaims: jwt.RegisteredClaims{
Subject: strconv.Itoa(int(user.Id)),
ExpiresAt: jwt.NewNumericDate(time.Now().Add(time.Hour)),
@@ -54,9 +53,11 @@ func GetUserFromToken(tokenString string) (User, error) {
return User{}, fmt.Errorf("invalid subject: %w", err)
}
var color [3]byte
copy(color[:], claims.Color)
return User{
Id: uint32(id),
Name: claims.Name,
Color: claims.Color,
Color: color,
}, nil
}