1
0
mirror of https://github.com/bitwarden/server.git synced 2025-06-30 15:42:48 -05:00

[AC-2602] Fix error when provider edits existing group (#4086)

* Add null check to groups endpoint - providers may not be OrgUsers
This commit is contained in:
Thomas Rittson
2024-05-16 00:17:15 +10:00
committed by GitHub
parent fd173e81b6
commit e619508f3f
2 changed files with 50 additions and 1 deletions

View File

@ -200,7 +200,8 @@ public class GroupsController : Controller
var userId = _userService.GetProperUserId(User).Value;
var organizationUser = await _organizationUserRepository.GetByOrganizationAsync(orgId, userId);
var currentGroupUsers = await _groupRepository.GetManyUserIdsByIdAsync(id);
if (!currentGroupUsers.Contains(organizationUser.Id) && model.Users.Contains(organizationUser.Id))
// OrganizationUser may be null if the current user is a provider
if (organizationUser != null && !currentGroupUsers.Contains(organizationUser.Id) && model.Users.Contains(organizationUser.Id))
{
throw new BadRequestException("You cannot add yourself to groups.");
}