1
0
mirror of https://github.com/bitwarden/server.git synced 2025-01-06 19:28:08 +01:00

Fixing errors.

This commit is contained in:
jrmccannon 2024-11-15 09:53:39 -06:00
parent 99f98f25ee
commit 78cd03d73b
No known key found for this signature in database
GPG Key ID: CF03F3DB01CE96A6

View File

@ -61,38 +61,38 @@ public class RevokeNonCompliantOrganizationUserCommand(IOrganizationUserReposito
{
if (!PerformedByIsAnExpectedType(request.ActionPerformedBy))
{
return new CommandResult([RequestedByWasNotValid]);
return new CommandResult([ErrorRequestedByWasNotValid]);
}
if (request.ActionPerformedBy is StandardUser loggableUser
&& request.OrganizationUsers.Any(x => x.UserId == loggableUser.UserId))
{
return new CommandResult([CannotRevokeSelfMessage]);
return new CommandResult([ErrorCannotRevokeSelf]);
}
if (request.OrganizationUsers.Any(x => x.OrganizationId != request.OrganizationId))
{
return new CommandResult([InvalidUsers]);
return new CommandResult([ErrorInvalidUsers]);
}
if (!await confirmedOwnersExceptQuery.HasConfirmedOwnersExceptAsync(
request.OrganizationId,
request.OrganizationUsers.Select(x => x.Id)))
{
return new CommandResult([OrgMustHaveAtLeastOneOwner]);
return new CommandResult([ErrorOrgMustHaveAtLeastOneOwner]);
}
return request.OrganizationUsers.Aggregate(new CommandResult(), (result, userToRevoke) =>
{
if (IsAlreadyRevoked(userToRevoke))
{
result.ErrorMessages.Add($"{UserAlreadyRevoked} Id: {userToRevoke.Id}");
result.ErrorMessages.Add($"{ErrorUserAlreadyRevoked} Id: {userToRevoke.Id}");
return result;
}
if (NonOwnersCannotRevokeOwners(userToRevoke, request.ActionPerformedBy))
{
result.ErrorMessages.Add($"{OnlyOwnersCanRevokeOtherOwners}");
result.ErrorMessages.Add($"{ErrorOnlyOwnersCanRevokeOtherOwners}");
return result;
}