mirror of
https://github.com/bitwarden/server.git
synced 2025-07-01 16:12:49 -05:00
Families for enterprise/fix new org sponsorship after deleted sponsored org (#1740)
* Sponsorship exists only if sponsored org is not null * Replace existing sponsorship if necessary * Update src/Core/Services/Implementations/OrganizationSponsorshipService.cs Co-authored-by: Robyn MacCallum <nickersthecat@gmail.com> * Fix tests Co-authored-by: Robyn MacCallum <nickersthecat@gmail.com>
This commit is contained in:
@ -98,7 +98,7 @@ namespace Bit.Core.Services
|
||||
|
||||
var existingOrgSponsorship = await _organizationSponsorshipRepository
|
||||
.GetBySponsoringOrganizationUserIdAsync(sponsoringOrgUser.Id);
|
||||
if (existingOrgSponsorship != null)
|
||||
if (existingOrgSponsorship?.SponsoredOrganizationId != null)
|
||||
{
|
||||
throw new BadRequestException("Can only sponsor one organization per Organization User.");
|
||||
}
|
||||
@ -113,9 +113,15 @@ namespace Bit.Core.Services
|
||||
CloudSponsor = true,
|
||||
};
|
||||
|
||||
if (existingOrgSponsorship != null)
|
||||
{
|
||||
// Replace existing invalid offer with our new sponsorship offer
|
||||
sponsorship.Id = existingOrgSponsorship.Id;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
sponsorship = await _organizationSponsorshipRepository.CreateAsync(sponsorship);
|
||||
await _organizationSponsorshipRepository.UpsertAsync(sponsorship);
|
||||
|
||||
await SendSponsorshipOfferAsync(sponsorship, sponsoringUserEmail);
|
||||
}
|
||||
|
Reference in New Issue
Block a user