mirror of
https://github.com/zitadel/zitadel.git
synced 2024-12-12 11:04:25 +00:00
fa9f581d56
* chore: move to new org * logging * fix: org rename caos -> zitadel Co-authored-by: adlerhurst <silvan.reusser@gmail.com>
50 lines
981 B
Go
50 lines
981 B
Go
package domain
|
|
|
|
import es_models "github.com/zitadel/zitadel/internal/eventstore/v1/models"
|
|
|
|
type ProjectGrant struct {
|
|
es_models.ObjectRoot
|
|
|
|
GrantID string
|
|
GrantedOrgID string
|
|
State ProjectGrantState
|
|
RoleKeys []string
|
|
}
|
|
|
|
type ProjectGrantIDs struct {
|
|
ProjectID string
|
|
GrantID string
|
|
}
|
|
|
|
type ProjectGrantState int32
|
|
|
|
const (
|
|
ProjectGrantStateUnspecified ProjectGrantState = iota
|
|
ProjectGrantStateActive
|
|
ProjectGrantStateInactive
|
|
ProjectGrantStateRemoved
|
|
)
|
|
|
|
func (p *ProjectGrant) IsValid() bool {
|
|
return p.GrantedOrgID != ""
|
|
}
|
|
|
|
func (g *ProjectGrant) HasInvalidRoles(validRoles []string) bool {
|
|
for _, roleKey := range g.RoleKeys {
|
|
if !containsRoleKey(roleKey, validRoles) {
|
|
return true
|
|
}
|
|
}
|
|
return false
|
|
}
|
|
|
|
func GetRemovedRoles(existingRoles, newRoles []string) []string {
|
|
removed := make([]string, 0)
|
|
for _, role := range existingRoles {
|
|
if !containsRoleKey(role, newRoles) {
|
|
removed = append(removed, role)
|
|
}
|
|
}
|
|
return removed
|
|
}
|