Skip to content

Commit

Permalink
fix: add check to confirm user being removed is the org admin
Browse files Browse the repository at this point in the history
  • Loading branch information
Chief-Rishab committed Sep 7, 2023
1 parent 92c5e60 commit a74896d
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions internal/api/v1beta1/group.go
Original file line number Diff line number Diff line change
Expand Up @@ -340,12 +340,12 @@ func (h Handler) RemoveGroupUser(ctx context.Context, request *frontierv1beta1.R
}
}

owners, err := h.userService.ListByGroup(ctx, request.GetId(), schema.OwnerRelationName)
owners, err := h.userService.ListByGroup(ctx, request.GetId(), schema.DeletePermission)
if err != nil {
logger.Error(err.Error())
return nil, grpcInternalServerError
}
if len(owners) == 1 {
if len(owners) == 1 && owners[0].ID == request.GetUserId() {
return nil, grpcMinOwnerCounrErr
}

Expand Down
2 changes: 1 addition & 1 deletion internal/api/v1beta1/org.go
Original file line number Diff line number Diff line change
Expand Up @@ -408,7 +408,7 @@ func (h Handler) RemoveOrganizationUser(ctx context.Context, request *frontierv1
logger.Error(err.Error())
return nil, grpcInternalServerError
}
if len(admins) == 1 {
if len(admins) == 1 && admins[0].ID == request.GetUserId() {
return nil, grpcMinAdminCountErr
}

Expand Down

0 comments on commit a74896d

Please sign in to comment.