1
0
mirror of https://github.com/bitwarden/server.git synced 2024-11-21 12:05:42 +01:00

Avoid sending "user need confirmation" emails when there are no org admins (#1960)

This commit is contained in:
Oscar Hinton 2022-04-20 21:05:21 +02:00 committed by GitHub
parent 244a33cdae
commit de997a2246
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1405,10 +1405,15 @@ namespace Bit.Core.Services
await _organizationUserRepository.ReplaceAsync(orgUser);
await _mailService.SendOrganizationAcceptedEmailAsync(
(await _organizationRepository.GetByIdAsync(orgUser.OrganizationId)),
user.Email,
(await _organizationUserRepository.GetManyByMinimumRoleAsync(orgUser.OrganizationId, OrganizationUserType.Admin)).Select(a => a.Email).Distinct());
var admins = await _organizationUserRepository.GetManyByMinimumRoleAsync(orgUser.OrganizationId, OrganizationUserType.Admin);
var adminEmails = admins.Select(a => a.Email).Distinct().ToList();
if (adminEmails.Count > 0)
{
var organization = await _organizationRepository.GetByIdAsync(orgUser.OrganizationId);
await _mailService.SendOrganizationAcceptedEmailAsync(organization, user.Email, adminEmails);
}
return orgUser;
}