Reject last owner demotion
Return a conflict when membership role updates would demote the final active owner in an organization. Add an end-to-end regression that verifies the mutation fails and leaves the owner role intact. Signed-off-by: Cursor Agent <cursoragent@cursor.com>
This commit is contained in:
committed by
Bryan Frimin
parent
88eb340aba
commit
e9bcdc85f4
@@ -63,6 +63,10 @@ func (r *mutationResolver) UpdateMembership(ctx context.Context, input types.Upd
|
||||
|
||||
membership, err := r.iam.OrganizationService.UpdateMembership(ctx, input.OrganizationID, input.MembershipID, input.Role)
|
||||
if err != nil {
|
||||
if _, ok := errors.AsType[*iam.ErrLastActiveOwner](err); ok {
|
||||
return nil, gqlutils.Conflictf(ctx, "cannot demote last active owner")
|
||||
}
|
||||
|
||||
r.logger.ErrorCtx(ctx, "cannot update membership", log.Error(err))
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user