mirror of
https://github.com/zitadel/zitadel.git
synced 2024-12-14 20:08:02 +00:00
ecfb9d0d6d
# Which Problems Are Solved Imporve the performance of user grant addition, especially for import. # How the Problems Are Solved Use the search table to query for the project grant state. This could easily be done by making the search used in `checkProjectGrantPreCondition` reusable. # Additional Changes Chanded event declerations to `const` in the `internal/repository/project` package. # Additional Context - Performance improvements for import are evaluated and acted upon internally at the moment --------- Co-authored-by: adlerhurst <silvan.reusser@gmail.com> Co-authored-by: Livio Spring <livio.a@gmail.com>
51 lines
1.0 KiB
Go
51 lines
1.0 KiB
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 ProjectGrantState int32
|
|
|
|
const (
|
|
ProjectGrantStateUnspecified ProjectGrantState = iota
|
|
ProjectGrantStateActive
|
|
ProjectGrantStateInactive
|
|
ProjectGrantStateRemoved
|
|
|
|
projectGrantStateMax
|
|
)
|
|
|
|
func (s ProjectGrantState) Valid() bool {
|
|
return s > ProjectGrantStateUnspecified && s < projectGrantStateMax
|
|
}
|
|
|
|
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
|
|
}
|