summaryrefslogtreecommitdiff
path: root/server/guest/models.go
blob: e4845699aba178a62e52c0e85fa64774ca541025 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
package guest

import (
	"time"

	"github.com/golang-jwt/jwt/v5"
)

type Guest struct {
	Id         string `json:"id"`
	FirstName  string `json:"firstName"`
	LastName   string `json:"lastName"`
	Attendance string `json:"attendance"`
	Email      string `json:"email"`
	Message    string `json:"message"`
	PartySize  int    `json:"partySize"`
	PartyList  []Name `json:"partyList"`
}

type Name struct {
	FirstName string `json:"firstName"`
	LastName  string `json:"lastName"`
}

type Claims struct {
	Name Name `json:"name"`
	jwt.RegisteredClaims
}

type Login struct {
	Guest Guest  `json:"guest"`
	Token string `json:"token"`
}

func NewClaims(name Name, time time.Time) *Claims {
	return &Claims{
		Name: name,
		RegisteredClaims: jwt.RegisteredClaims{
			ExpiresAt: jwt.NewNumericDate(time),
		},
	}
}

func NewLogin(guest Guest, token string) *Login {
	return &Login{
		Guest: guest,
		Token: token,
	}
}