1
0
mirror of https://github.com/bitwarden/server.git synced 2025-04-05 05:00:19 -05:00

Using GetPlanOrThrow instead.

This commit is contained in:
jrmccannon 2025-03-28 09:10:18 -05:00
parent b933007f09
commit a1bd46febf
No known key found for this signature in database
GPG Key ID: CF03F3DB01CE96A6

View File

@ -28,8 +28,7 @@ public class PostUserCommand(
IFeatureService featureService, IFeatureService featureService,
IInviteOrganizationUsersCommand inviteOrganizationUsersCommand, IInviteOrganizationUsersCommand inviteOrganizationUsersCommand,
TimeProvider timeProvider, TimeProvider timeProvider,
IPricingClient pricingClient, IPricingClient pricingClient)
ILogger<PostUserCommand> logger)
: IPostUserCommand : IPostUserCommand
{ {
public async Task<OrganizationUserUserDetails?> PostUserAsync(Guid organizationId, ScimUserRequestModel model) public async Task<OrganizationUserUserDetails?> PostUserAsync(Guid organizationId, ScimUserRequestModel model)
@ -54,26 +53,17 @@ public class PostUserCommand(
throw new NotFoundException(); throw new NotFoundException();
} }
var plan = await pricingClient.GetPlan(organization.PlanType); var plan = await pricingClient.GetPlanOrThrow(organization.PlanType);
if (plan == null)
{
logger.LogError("Plan {planType} not found for organization {organizationId}",
organization.PlanType, organization.Id);
return null;
}
var hasSecretsManagerStandalone = await paymentService.HasSecretsManagerStandalone(organization); var hasSecretsManagerStandalone = await paymentService.HasSecretsManagerStandalone(organization);
var request = model.ToRequest( var request = model.ToRequest(
scimProvider: scimProvider, scimProvider: scimProvider,
inviteOrganization: new InviteOrganization(organization, plan), inviteOrganization: new InviteOrganization(organization, plan),
performedAt: timeProvider.GetUtcNow(), performedAt: timeProvider.GetUtcNow());
hasSecretsManagerStandalone);
var orgUsers = var orgUsers = await organizationUserRepository
await organizationUserRepository.GetManyDetailsByOrganizationAsync( .GetManyDetailsByOrganizationAsync(request.InviteOrganization.OrganizationId);
request.InviteOrganization.OrganizationId);
if (orgUsers.Any(existingUser => if (orgUsers.Any(existingUser =>
request.Invites.First().Email.Equals(existingUser.Email, StringComparison.OrdinalIgnoreCase) || request.Invites.First().Email.Equals(existingUser.Email, StringComparison.OrdinalIgnoreCase) ||