1
0
mirror of https://github.com/bitwarden/server.git synced 2025-04-10 15:48:13 -05:00

Use consistent exception type

This commit is contained in:
Thomas Rittson 2025-04-02 12:28:46 +10:00
parent 84447bfc05
commit a42f21159f
No known key found for this signature in database
GPG Key ID: CDDDA03861C35E27

View File

@ -3,7 +3,6 @@
using Bit.Core.AdminConsole.Repositories; using Bit.Core.AdminConsole.Repositories;
using Bit.Core.Services; using Bit.Core.Services;
using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Authorization;
using BadRequestException = Bit.Core.Exceptions.BadRequestException;
namespace Bit.Api.AdminConsole.Authorization; namespace Bit.Api.AdminConsole.Authorization;
@ -32,7 +31,7 @@ public class OrganizationRequirementHandler(
var userId = userService.GetProperUserId(httpContext.User); var userId = userService.GetProperUserId(httpContext.User);
if (userId == null) if (userId == null)
{ {
throw new BadRequestException("This method should only be called on the private api with a logged in user."); throw new InvalidOperationException("This method should only be called on the private api with a logged in user.");
} }
Task<bool> IsProviderUserForOrg() => httpContextAccessor.HttpContext.IsProviderUserForOrgAsync(providerUserRepository, userId.Value, organizationId); Task<bool> IsProviderUserForOrg() => httpContextAccessor.HttpContext.IsProviderUserForOrgAsync(providerUserRepository, userId.Value, organizationId);