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:
Fabi
2021-07-01 15:53:52 +02:00
committed by GitHub
parent c6ad784a6c
commit 2037d7d41c
4 changed files with 10 additions and 5 deletions

View File

@@ -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