-
Notifications
You must be signed in to change notification settings - Fork 0
/
model.go
89 lines (82 loc) · 4.74 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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
package nibbler
import (
"time"
)
type User struct {
ID string `json:"id" bson:"_id" gorm:"primary_key"` // ID
CreatedAt time.Time `json:"createdAt"`
UpdatedAt time.Time `json:"updatedAt"`
DeletedAt *time.Time `json:"deletedAt,omitempty" sql:"index"`
Email *string `json:"email,omitempty" gorm:"unique"`
Username *string `json:"username,omitempty" gorm:"unique"`
FirstName *string `json:"firstName,omitempty"`
LastName *string `json:"lastName,omitempty"`
Title *string `json:"title,omitempty"`
Password *string `json:"password,omitempty"`
PortraitUri *string `json:"portraitUri,omitempty"`
AvatarUri *string `json:"avatarUri,omitempty"`
StatusText *string `json:"statusText,omitempty"`
IsActive *bool `json:"isActive,omitempty"`
IsEmailValidated *bool `json:"isEmailValidated,omitempty"`
DeactivatedAt *time.Time `json:"deactivatedAt,omitempty"`
LastLogin *time.Time `json:"lastLogin,omitempty"`
FailedLoginCount *int8 `json:"failedLoginCount,omitempty"`
Gender *string `json:"gender,omitempty" gorm:"size:1"`
PhoneHome *string `json:"phoneHome,omitempty" gorm:"size:24"`
PhoneWork *string `json:"phoneWork,omitempty" gorm:"size:24"`
PhoneMobile *string `json:"phoneMobile,omitempty" gorm:"size:24"`
PhoneOther *string `json:"phoneOther,omitempty" gorm:"size:24"`
Fax *string `json:"fax,omitempty" gorm:"size:24"`
Uri *string `json:"uri,omitempty"`
Birthday *string `json:"birthday,omitempty"`
Bio *string `json:"bio,omitempty"`
AddressLine1 *string `json:"addressLine1,omitempty"`
AddressLine2 *string `json:"addressLine2,omitempty"`
AddressLine3 *string `json:"addressLine3,omitempty"`
AddressCity *string `json:"addressCity,omitempty"`
AddressStateOrProvince *string `json:"addressStateOrProvince,omitempty"`
AddressPostalCode *string `gorm:"size:16" json:"postalCode,omitempty"`
CountryCode *string `gorm:"size:3" json:"countryCode,omitempty"`
EmployeeId *string `json:"employeeId,omitempty"`
ReferenceId *string `json:"referenceId,omitempty"`
PasswordResetToken *string `json:"passwordResetToken,omitempty"`
PasswordResetExpiration *time.Time `json:"passwordResetExpiration,omitempty"`
EmailValidationToken *string `json:"emailValidationToken,omitempty"`
EmailValidationExpiration *time.Time `json:"emailValidationExpiration,omitempty"`
EmploymentStartDate *time.Time `json:"employmentStartDate,omitempty"`
EmploymentEndDate *time.Time `json:"employmentEndDate,omitempty"`
ContractStartDate *time.Time `json:"contractStartDate,omitempty"`
ContractEndDate *time.Time `json:"contractEndDate,omitempty"`
PrimaryLocation *string `json:"primaryLocation,omitempty"` // e.g. lat/long, grid codes, etc
Context *string `json:"context,omitempty"`
ProtectedContext *string `json:"protectedContext,omitempty"`
}
// basic model for both role-based and group privilege-based auth control
type Group struct {
ID string `json:"id" bson:"_id" gorm:"primary_key"`
CreatedAt time.Time `json:"createdAt"`
UpdatedAt time.Time `json:"updatedAt"`
DeletedAt *time.Time `json:"deletedAt,omitempty" sql:"index"`
Name string `json:"name"`
Type string `json:"type"`
}
type GroupMembership struct {
ID string `json:"id" bson:"_id" gorm:"primary_key"`
CreatedAt time.Time `json:"createdAt"`
UpdatedAt time.Time `json:"updatedAt"`
DeletedAt *time.Time `json:"deletedAt,omitempty" sql:"index"`
GroupID string `json:"groupId"`
MemberID string `json:"memberId"`
Role GroupRole `json:"role"`
}
type GroupPrivilege struct {
ID string `json:"id" bson:"_id" gorm:"primary_key"`
CreatedAt time.Time `json:"createdAt"`
UpdatedAt time.Time `json:"updatedAt"`
DeletedAt *time.Time `json:"deletedAt,omitempty" sql:"index"`
PerformingGroupID string `json:"performingGroupID"` // e.g. "administrators" ID
TargetGroupID string `json:"targetGroupID"` // e.g. "customers" ID
Action int `json:"action"` // e.g. read/write/admin/etc
}
type GroupRole int // make your own roles
type Action int // make your own actions