lavender/server/owners.go

34 lines
656 B
Go
Raw Normal View History

2023-10-27 09:40:10 +01:00
package server
2023-11-15 09:21:09 +00:00
// UserConfig is the structure for storing a user's role and owned domains
type UserConfig map[string]struct {
Roles []string `json:"roles"`
Domains []string `json:"domains"`
}
func (u UserConfig) AllRoles(user string) []string {
return u[user].Roles
}
func (u UserConfig) HasRole(user, role string) bool {
for _, i := range u[user].Roles {
if i == role {
return true
}
}
return false
}
2023-10-27 09:40:10 +01:00
2023-11-15 09:21:09 +00:00
func (u UserConfig) AllDomains(user string) []string {
return u[user].Domains
2023-10-27 09:40:10 +01:00
}
2023-11-15 09:21:09 +00:00
func (u UserConfig) OwnsDomain(user, domain string) bool {
for _, i := range u[user].Domains {
2023-10-27 09:40:10 +01:00
if i == domain {
return true
}
}
return false
}