-
Notifications
You must be signed in to change notification settings - Fork 0
/
Permissions.go
54 lines (47 loc) · 1.39 KB
/
Permissions.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
package dataModel
type LeaguePermissionsCore struct {
Administrator bool `json:"administrator"`
CreateTeams bool `json:"createTeams"`
EditTeams bool `json:"editTeams"`
EditGames bool `json:"editGames"`
}
func (p *LeaguePermissionsCore) Validate() (bool, string, error) {
return validate(p.consistent())
}
func (p *LeaguePermissionsCore) consistent() ValidateFunc {
return func(problemDest *string, _ *error) bool {
if (p.CreateTeams || p.EditGames || p.EditTeams) && p.Administrator {
*problemDest = AdminLackingPermissions
return false
} else {
return true
}
}
}
type TeamPermissionsCore struct {
Administrator bool `json:"administrator"`
Information bool `json:"information"`
Games bool `json:"games"`
}
func (p *TeamPermissionsCore) Validate() (bool, string, error) {
return validate(p.consistent())
}
func (p *TeamPermissionsCore) consistent() ValidateFunc {
return func(problemDest *string, _ *error) bool {
if (p.Information || p.Games) && p.Administrator {
*problemDest = AdminLackingPermissions
return false
} else {
return true
}
}
}
type TeamPermissions struct {
TeamId int `json:"teamId"`
Name string `json:"name"`
Tag string `json:"tag"`
IconSmall string `json:"iconSmall"`
Administrator bool `json:"administrator"`
Information bool `json:"information"`
Games bool `json:"games"`
}