mirror of
https://github.com/zitadel/zitadel.git
synced 2025-08-12 11:27:33 +00:00
fix: usergrant pre condition check (#1947)
* fix: usergrant pre condition check * fix: usergrant pre condition check * fix: usergrant pre condition check
This commit is contained in:
@@ -92,7 +92,7 @@ func (c *Commands) changeUserGrant(ctx context.Context, userGrant *domain.UserGr
|
||||
if reflect.DeepEqual(existingUserGrant.RoleKeys, userGrant.RoleKeys) {
|
||||
return nil, nil, caos_errs.ThrowPreconditionFailed(nil, "COMMAND-Rs8fy", "Errors.UserGrant.NotChanged")
|
||||
}
|
||||
err = c.checkUserGrantPreCondition(ctx, userGrantWriteModelToUserGrant(existingUserGrant))
|
||||
err = c.checkUserGrantPreCondition(ctx, userGrant)
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
|
@@ -117,15 +117,18 @@ func (wm *UserGrantPreConditionReadModel) Reduce() error {
|
||||
case *project.GrantAddedEvent:
|
||||
if wm.ProjectGrantID == e.GrantID {
|
||||
wm.ProjectGrantExists = true
|
||||
wm.ExistingRoleKeys = e.RoleKeys
|
||||
}
|
||||
wm.ExistingRoleKeys = e.RoleKeys
|
||||
case *project.GrantChangedEvent:
|
||||
wm.ExistingRoleKeys = e.RoleKeys
|
||||
if wm.ProjectGrantID == e.GrantID {
|
||||
wm.ProjectGrantExists = true
|
||||
wm.ExistingRoleKeys = e.RoleKeys
|
||||
}
|
||||
case *project.GrantRemovedEvent:
|
||||
if wm.ProjectGrantID == e.GrantID {
|
||||
wm.ProjectGrantExists = false
|
||||
wm.ExistingRoleKeys = []string{}
|
||||
}
|
||||
wm.ExistingRoleKeys = []string{}
|
||||
case *project.RoleAddedEvent:
|
||||
if wm.ProjectGrantID != "" {
|
||||
continue
|
||||
|
Reference in New Issue
Block a user