woodpecker/server/plugins/permissions/orgs.go
qwerty287 fd77b2e9d7
Fix repo owner filter (#2808)
and move to server config instead of middleware

cc @xoxys 

closes #2784
2023-11-12 14:39:41 +01:00

27 lines
478 B
Go

package permissions
import (
"go.woodpecker-ci.org/woodpecker/server/model"
"go.woodpecker-ci.org/woodpecker/shared/utils"
)
func NewOrgs(orgs []string) *Orgs {
return &Orgs{
IsConfigured: len(orgs) > 0,
orgs: utils.SliceToBoolMap(orgs),
}
}
type Orgs struct {
IsConfigured bool
orgs map[string]bool
}
func (o *Orgs) IsMember(teams []*model.Team) bool {
for _, team := range teams {
if o.orgs[team.Login] {
return true
}
}
return false
}