mirror of
https://github.com/zitadel/zitadel.git
synced 2025-08-11 17:27:31 +00:00
Add uid to few events (#9332)
# Which Problems Are Solved When implementing simple stateless event processor, `the user.grant.changed` bears too little information: just grant id and list of role keys. This makes it impossible to change a users permissions solely based on available role keys and requires to either: - Store a mapping grant id -> user id, making a service stateful - Make an extra call to zitadel to resolve user id by grant id (And it doesn't seem that such an endpoint exists) Same with `user.grant.removed` events. # How the Problems Are Solved Added `userId` field to `user.grant.changed` and `user.grant.removed` events # Additional Changes `user.grant.removed` now has `projectId` and `grantId` as well # Additional Context - Closes #9113
This commit is contained in:
@@ -108,7 +108,7 @@ func (c *Commands) changeUserGrant(ctx context.Context, userGrant *domain.UserGr
|
||||
if cascade {
|
||||
return usergrant.NewUserGrantCascadeChangedEvent(ctx, userGrantAgg, userGrant.RoleKeys), existingUserGrant, nil
|
||||
}
|
||||
return usergrant.NewUserGrantChangedEvent(ctx, userGrantAgg, userGrant.RoleKeys), existingUserGrant, nil
|
||||
return usergrant.NewUserGrantChangedEvent(ctx, userGrantAgg, existingUserGrant.UserID, userGrant.RoleKeys), existingUserGrant, nil
|
||||
}
|
||||
|
||||
func (c *Commands) removeRoleFromUserGrant(ctx context.Context, userGrantID string, roleKeys []string, cascade bool) (_ eventstore.Command, err error) {
|
||||
@@ -141,7 +141,7 @@ func (c *Commands) removeRoleFromUserGrant(ctx context.Context, userGrantID stri
|
||||
return usergrant.NewUserGrantCascadeChangedEvent(ctx, userGrantAgg, existingUserGrant.RoleKeys), nil
|
||||
}
|
||||
|
||||
return usergrant.NewUserGrantChangedEvent(ctx, userGrantAgg, existingUserGrant.RoleKeys), nil
|
||||
return usergrant.NewUserGrantChangedEvent(ctx, userGrantAgg, existingUserGrant.UserID, existingUserGrant.RoleKeys), nil
|
||||
}
|
||||
|
||||
func (c *Commands) DeactivateUserGrant(ctx context.Context, grantID, resourceOwner string) (objectDetails *domain.ObjectDetails, err error) {
|
||||
|
@@ -1073,6 +1073,7 @@ func TestCommandSide_ChangeUserGrant(t *testing.T) {
|
||||
expectPush(
|
||||
usergrant.NewUserGrantChangedEvent(context.Background(),
|
||||
&usergrant.NewAggregate("usergrant1", "org1").Aggregate,
|
||||
"user1",
|
||||
[]string{"rolekey1", "rolekey2"},
|
||||
),
|
||||
),
|
||||
@@ -1167,6 +1168,7 @@ func TestCommandSide_ChangeUserGrant(t *testing.T) {
|
||||
expectPush(
|
||||
usergrant.NewUserGrantChangedEvent(context.Background(),
|
||||
&usergrant.NewAggregate("usergrant1", "org1").Aggregate,
|
||||
"user1",
|
||||
[]string{"rolekey1", "rolekey2"},
|
||||
),
|
||||
),
|
||||
|
Reference in New Issue
Block a user