Notes2/user.go

28 lines
499 B
Go
Raw Normal View History

2024-11-28 18:11:14 +01:00
package main
import (
// External
"github.com/golang-jwt/jwt/v5"
)
2025-01-12 17:35:29 +01:00
type UserSession struct {
UserID int
Username string
Password string
Name string
ClientUUID string
2024-11-28 18:11:14 +01:00
}
2025-01-12 17:35:29 +01:00
func NewUser(claims jwt.MapClaims) (u UserSession) {
2024-11-28 18:11:14 +01:00
uid, _ := claims["uid"].(float64)
name, _ := claims["name"].(string)
username, _ := claims["login"].(string)
2025-01-12 17:35:29 +01:00
clientUUID, _ := claims["cid"].(string)
2024-11-28 18:11:14 +01:00
2025-01-12 17:35:29 +01:00
u.UserID = int(uid)
2024-11-28 18:11:14 +01:00
u.Username = username
u.Name = name
2025-01-12 17:35:29 +01:00
u.ClientUUID = clientUUID
2024-11-28 18:11:14 +01:00
return
}