2021-01-12 11:59:51 +00:00
|
|
|
package domain
|
|
|
|
|
|
|
|
import (
|
2021-02-23 14:13:04 +00:00
|
|
|
"github.com/caos/zitadel/internal/eventstore/v1/models"
|
2021-01-12 11:59:51 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
type ProjectRole struct {
|
|
|
|
models.ObjectRoot
|
|
|
|
|
|
|
|
Key string
|
|
|
|
DisplayName string
|
|
|
|
Group string
|
|
|
|
}
|
|
|
|
|
2021-01-28 05:35:26 +00:00
|
|
|
type ProjectRoleState int32
|
|
|
|
|
|
|
|
const (
|
|
|
|
ProjectRoleStateUnspecified ProjectRoleState = iota
|
|
|
|
ProjectRoleStateActive
|
|
|
|
ProjectRoleStateRemoved
|
|
|
|
)
|
|
|
|
|
2021-01-12 11:59:51 +00:00
|
|
|
func NewProjectRole(projectID, key string) *ProjectRole {
|
|
|
|
return &ProjectRole{ObjectRoot: models.ObjectRoot{AggregateID: projectID}, Key: key}
|
|
|
|
}
|
|
|
|
|
|
|
|
func (p *ProjectRole) IsValid() bool {
|
|
|
|
return p.AggregateID != "" && p.Key != ""
|
|
|
|
}
|
2021-03-15 11:51:15 +00:00
|
|
|
|
|
|
|
func containsRoleKey(roleKey string, validRoles []string) bool {
|
|
|
|
for _, validRole := range validRoles {
|
|
|
|
if roleKey == validRole {
|
|
|
|
return true
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return false
|
|
|
|
}
|