2021-01-12 12:59:51 +01:00
|
|
|
package domain
|
|
|
|
|
|
|
|
import (
|
2022-04-27 01:01:45 +02:00
|
|
|
"github.com/zitadel/zitadel/internal/eventstore/v1/models"
|
2021-01-12 12:59:51 +01:00
|
|
|
)
|
|
|
|
|
|
|
|
type ProjectRole struct {
|
|
|
|
models.ObjectRoot
|
|
|
|
|
|
|
|
Key string
|
|
|
|
DisplayName string
|
|
|
|
Group string
|
|
|
|
}
|
|
|
|
|
2021-01-28 06:35:26 +01:00
|
|
|
type ProjectRoleState int32
|
|
|
|
|
|
|
|
const (
|
|
|
|
ProjectRoleStateUnspecified ProjectRoleState = iota
|
|
|
|
ProjectRoleStateActive
|
|
|
|
ProjectRoleStateRemoved
|
|
|
|
)
|
|
|
|
|
2021-01-12 12:59:51 +01: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 12:51:15 +01:00
|
|
|
|
|
|
|
func containsRoleKey(roleKey string, validRoles []string) bool {
|
|
|
|
for _, validRole := range validRoles {
|
|
|
|
if roleKey == validRole {
|
|
|
|
return true
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return false
|
|
|
|
}
|