Skip to content

Commit

Permalink
MG-2201 - Fail role update if user does not exist (#2234)
Browse files Browse the repository at this point in the history
Signed-off-by: JeffMboya <jangina.mboya@gmail.com>
  • Loading branch information
JeffMboya committed Jun 12, 2024
1 parent 487dcc6 commit 6cabc23
Show file tree
Hide file tree
Showing 2 changed files with 236 additions and 154 deletions.
5 changes: 5 additions & 0 deletions users/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -383,9 +383,14 @@ func (svc service) UpdateClientRole(ctx context.Context, token string, cli mgcli
UpdatedBy: tokenUserID,
}

if _, err := svc.authorize(ctx, auth.UserType, auth.UsersKind, client.ID, auth.MembershipPermission, auth.PlatformType, auth.MagistralaObject); err != nil {
return mgclients.Client{}, err
}

if err := svc.updateClientPolicy(ctx, cli.ID, cli.Role); err != nil {
return mgclients.Client{}, err
}

client, err = svc.clients.UpdateRole(ctx, client)
if err != nil {
// If failed to update role in DB, then revert back to platform admin policy in spicedb
Expand Down
Loading

0 comments on commit 6cabc23

Please sign in to comment.