mirror of
https://github.com/bitwarden/server.git
synced 2025-04-05 05:00:19 -05:00
Added provider email addresses as well.
This commit is contained in:
parent
27d6d0d731
commit
8d2c723c09
@ -1,7 +1,10 @@
|
|||||||
using Bit.Core.AdminConsole.Entities;
|
using Bit.Core.AdminConsole.Entities;
|
||||||
|
using Bit.Core.AdminConsole.Enums.Provider;
|
||||||
using Bit.Core.AdminConsole.Interfaces;
|
using Bit.Core.AdminConsole.Interfaces;
|
||||||
|
using Bit.Core.AdminConsole.Models.Business;
|
||||||
using Bit.Core.AdminConsole.OrganizationFeatures.OrganizationUsers.InviteUsers.Models;
|
using Bit.Core.AdminConsole.OrganizationFeatures.OrganizationUsers.InviteUsers.Models;
|
||||||
using Bit.Core.AdminConsole.OrganizationFeatures.OrganizationUsers.InviteUsers.Validation;
|
using Bit.Core.AdminConsole.OrganizationFeatures.OrganizationUsers.InviteUsers.Validation;
|
||||||
|
using Bit.Core.AdminConsole.Repositories;
|
||||||
using Bit.Core.AdminConsole.Shared.Validation;
|
using Bit.Core.AdminConsole.Shared.Validation;
|
||||||
using Bit.Core.Context;
|
using Bit.Core.Context;
|
||||||
using Bit.Core.Entities;
|
using Bit.Core.Entities;
|
||||||
@ -31,7 +34,9 @@ public class InviteOrganizationUsersCommand(IEventService eventService,
|
|||||||
IMailService mailService,
|
IMailService mailService,
|
||||||
ILogger<InviteOrganizationUsersCommand> logger,
|
ILogger<InviteOrganizationUsersCommand> logger,
|
||||||
IUpdateSecretsManagerSubscriptionCommand updateSecretsManagerSubscriptionCommand,
|
IUpdateSecretsManagerSubscriptionCommand updateSecretsManagerSubscriptionCommand,
|
||||||
ISendOrganizationInvitesCommand sendOrganizationInvitesCommand
|
ISendOrganizationInvitesCommand sendOrganizationInvitesCommand,
|
||||||
|
IProviderOrganizationRepository providerOrganizationRepository,
|
||||||
|
IProviderUserRepository providerUserRepository
|
||||||
) : IInviteOrganizationUsersCommand
|
) : IInviteOrganizationUsersCommand
|
||||||
{
|
{
|
||||||
|
|
||||||
@ -200,12 +205,7 @@ public class InviteOrganizationUsersCommand(IEventService eventService,
|
|||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
// TODO include provider org emails
|
var ownerEmails = await GetOwnerEmailAddressesAsync(validatedResult.Value.InviteOrganization);
|
||||||
|
|
||||||
var ownerEmails = (await organizationUserRepository
|
|
||||||
.GetManyByMinimumRoleAsync(validatedResult.Value.InviteOrganization.OrganizationId, OrganizationUserType.Owner))
|
|
||||||
.Select(x => x.Email)
|
|
||||||
.Distinct();
|
|
||||||
|
|
||||||
await mailService.SendOrganizationMaxSeatLimitReachedEmailAsync(organization,
|
await mailService.SendOrganizationMaxSeatLimitReachedEmailAsync(organization,
|
||||||
validatedResult.Value.PasswordManagerSubscriptionUpdate.MaxAutoScaleSeats!.Value, ownerEmails);
|
validatedResult.Value.PasswordManagerSubscriptionUpdate.MaxAutoScaleSeats!.Value, ownerEmails);
|
||||||
@ -216,6 +216,24 @@ public class InviteOrganizationUsersCommand(IEventService eventService,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private async Task<IEnumerable<string>> GetOwnerEmailAddressesAsync(InviteOrganization organization)
|
||||||
|
{
|
||||||
|
var providerOrganization = await providerOrganizationRepository
|
||||||
|
.GetByOrganizationId(organization.OrganizationId);
|
||||||
|
|
||||||
|
if (providerOrganization == null)
|
||||||
|
{
|
||||||
|
return (await organizationUserRepository
|
||||||
|
.GetManyByMinimumRoleAsync(organization.OrganizationId, OrganizationUserType.Owner))
|
||||||
|
.Select(x => x.Email)
|
||||||
|
.Distinct();
|
||||||
|
}
|
||||||
|
|
||||||
|
return (await providerUserRepository
|
||||||
|
.GetManyDetailsByProviderAsync(providerOrganization.ProviderId, ProviderUserStatusType.Confirmed))
|
||||||
|
.Select(u => u.Email).Distinct();
|
||||||
|
}
|
||||||
|
|
||||||
private async Task AdjustSecretsManagerSeatsAsync(Valid<InviteUserOrganizationValidationRequest> validatedResult, Organization organization)
|
private async Task AdjustSecretsManagerSeatsAsync(Valid<InviteUserOrganizationValidationRequest> validatedResult, Organization organization)
|
||||||
{
|
{
|
||||||
if (validatedResult.Value.SecretsManagerSubscriptionUpdate.SeatsRequiredToAdd <= 0)
|
if (validatedResult.Value.SecretsManagerSubscriptionUpdate.SeatsRequiredToAdd <= 0)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user