1
0
mirror of https://github.com/bitwarden/server synced 2025-12-18 01:03:17 +00:00

Invite Client owner at time of client org creation (#1488)

This commit is contained in:
Matt Gibson
2021-07-30 08:10:58 -05:00
committed by GitHub
parent fdaf6b14d4
commit 2298c96e30
6 changed files with 42 additions and 8 deletions

View File

@@ -7,6 +7,7 @@ using Bit.Core.Enums.Provider;
using Bit.Core.Exceptions;
using Bit.Core.Models.Business;
using Bit.Core.Models.Business.Provider;
using Bit.Core.Models.Data;
using Bit.Core.Models.Table;
using Bit.Core.Models.Table.Provider;
using Bit.Core.Repositories;
@@ -374,7 +375,8 @@ namespace Bit.CommCore.Services
await _eventService.LogProviderOrganizationEventAsync(providerOrganization, EventType.ProviderOrganization_Added);
}
public async Task<ProviderOrganization> CreateOrganizationAsync(Guid providerId, OrganizationSignup organizationSignup, User user)
public async Task<ProviderOrganization> CreateOrganizationAsync(Guid providerId,
OrganizationSignup organizationSignup, string clientOwnerEmail, User user)
{
var (organization, _) = await _organizationService.SignUpAsync(organizationSignup, true);
@@ -388,6 +390,15 @@ namespace Bit.CommCore.Services
await _providerOrganizationRepository.CreateAsync(providerOrganization);
await _eventService.LogProviderOrganizationEventAsync(providerOrganization, EventType.ProviderOrganization_Created);
await _organizationService.InviteUserAsync(organization.Id, user.Id, null, new OrganizationUserInvite
{
Emails = new[] { clientOwnerEmail },
AccessAll = true,
Type = OrganizationUserType.Owner,
Permissions = null,
Collections = Array.Empty<SelectionReadOnly>(),
});
return providerOrganization;
}