mirror of
https://github.com/bitwarden/server.git
synced 2025-04-21 04:55:08 -05:00
parent
3f598c35fc
commit
54c46f716b
@ -1012,12 +1012,20 @@ namespace Bit.Core.Services
|
|||||||
throw new BadRequestException("Invite the user first.");
|
throw new BadRequestException("Invite the user first.");
|
||||||
}
|
}
|
||||||
|
|
||||||
if(savingUserId.HasValue && user.Type == OrganizationUserType.Owner)
|
if(savingUserId.HasValue)
|
||||||
{
|
{
|
||||||
var savingUserOrgs = await _organizationUserRepository.GetManyByUserAsync(savingUserId.Value);
|
var savingUserOrgs = await _organizationUserRepository.GetManyByUserAsync(savingUserId.Value);
|
||||||
if(!savingUserOrgs.Any(u => u.OrganizationId == user.OrganizationId && u.Type == OrganizationUserType.Owner))
|
var savingUserIsOrgOwner = savingUserOrgs
|
||||||
|
.Any(u => u.OrganizationId == user.OrganizationId && u.Type == OrganizationUserType.Owner);
|
||||||
|
if(!savingUserIsOrgOwner)
|
||||||
{
|
{
|
||||||
throw new BadRequestException("Only owners can update other owners.");
|
var originalUser = await _organizationUserRepository.GetByIdAsync(user.Id);
|
||||||
|
var isOwner = originalUser.Type == OrganizationUserType.Owner;
|
||||||
|
var nowOwner = user.Type == OrganizationUserType.Owner;
|
||||||
|
if((isOwner && !nowOwner) || (!isOwner && nowOwner))
|
||||||
|
{
|
||||||
|
throw new BadRequestException("Only an owner can change the user type of another owner.");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user