25 lines
382 B
Go
25 lines
382 B
Go
package main
|
|
|
|
import (
|
|
// External
|
|
"github.com/golang-jwt/jwt/v5"
|
|
)
|
|
|
|
type User struct {
|
|
ID int
|
|
Username string
|
|
Password string
|
|
Name string
|
|
}
|
|
|
|
func NewUser(claims jwt.MapClaims) (u User) {
|
|
uid, _ := claims["uid"].(float64)
|
|
name, _ := claims["name"].(string)
|
|
username, _ := claims["login"].(string)
|
|
|
|
u.ID = int(uid)
|
|
u.Username = username
|
|
u.Name = name
|
|
return
|
|
}
|