-
Notifications
You must be signed in to change notification settings - Fork 0
/
model.go
40 lines (34 loc) · 1.09 KB
/
model.go
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
package main
import (
jwt "github.com/dgrijalva/jwt-go"
"go.mongodb.org/mongo-driver/bson/primitive"
)
// Used to read the email and password from the token
// request body (signin use case)
type Credentials struct {
Email string `json:"email"`
Password string `json:"password"`
}
// Used to serialize token as a response to authentication request
type Token struct {
Token string `json:"token"`
}
type ResponseResult struct {
Error string `json:"error"`
Result string `json:"result"`
}
// Struct that will be encoded to a JWT.
// We add jwt.StandardClaims as an embedded type, to provide fields
// like expiry time
type Claims struct {
Email string `json:"email"`
jwt.StandardClaims
}
// this becomes part of context that is propagated to all handlers - e.g. graphql
type UserProfile struct {
Id primitive.ObjectID `json:"id" bson:"_id,omitempty"`
Email string `json:"email" bson:"email"`
IsAdmin bool `json:"is_admin" bson:"is_admin"`
OrgId primitive.ObjectID `json:"org_id" bson:"org_id"`
OrgIds []primitive.ObjectID `json:"orgs" bson:"orgs"`
}