mirror of
https://github.com/woodpecker-ci/woodpecker.git
synced 2024-11-14 05:51:37 +00:00
24 lines
677 B
Go
24 lines
677 B
Go
package model
|
|
|
|
// Config defines system configuration parameters.
|
|
type Config struct {
|
|
Open bool // Enables open registration
|
|
Secret string // Secret token used to authenticate agents
|
|
Admins map[string]bool // Administrative users
|
|
Orgs map[string]bool // Organization whitelist
|
|
}
|
|
|
|
// IsAdmin returns true if the user is a member of the administrator list.
|
|
func (c *Config) IsAdmin(user *User) bool {
|
|
return c.Admins[user.Login]
|
|
}
|
|
|
|
// IsMember returns true if the user is a member of the whitelisted teams.
|
|
func (c *Config) IsMember(teams []*Team) bool {
|
|
for _, team := range teams {
|
|
if c.Orgs[team.Login] {
|
|
return true
|
|
}
|
|
}
|
|
return false
|
|
}
|