1
0
mirror of https://github.com/bitwarden/server synced 2025-12-28 22:23:30 +00:00

[PM-17775] (#5699)

* Changes to allow admin to send F4E sponsorship

* Fix the failing unit tests

* Fix the failing test

Signed-off-by: Cy Okeke <cokeke@bitwarden.com>

* Merge Changes with pm-17777

Signed-off-by: Cy Okeke <cokeke@bitwarden.com>

* Add changes for autoscale

Signed-off-by: Cy Okeke <cokeke@bitwarden.com>

* Return the right error response

Signed-off-by: Cy Okeke <cokeke@bitwarden.com>

* Resolve the failing unit test

Signed-off-by: Cy Okeke <cokeke@bitwarden.com>

---------

Signed-off-by: Cy Okeke <cokeke@bitwarden.com>
This commit is contained in:
cyprain-okeke
2025-05-01 16:35:51 +01:00
committed by GitHub
parent 8ecd9c5fb3
commit dc5db5673f
4 changed files with 161 additions and 8 deletions

View File

@@ -47,11 +47,12 @@ public class CreateSponsorshipCommand(
throw new BadRequestException("Only confirmed users can sponsor other organizations.");
}
var existingOrgSponsorship = await organizationSponsorshipRepository
.GetBySponsoringOrganizationUserIdAsync(sponsoringMember.Id);
if (existingOrgSponsorship?.SponsoredOrganizationId != null)
var sponsorships =
await organizationSponsorshipRepository.GetManyBySponsoringOrganizationAsync(sponsoringOrganization.Id);
var existingSponsorship = sponsorships.FirstOrDefault(s => s.FriendlyName == friendlyName);
if (existingSponsorship != null)
{
throw new BadRequestException("Can only sponsor one organization per Organization User.");
return existingSponsorship;
}
if (isAdminInitiated)
@@ -70,10 +71,20 @@ public class CreateSponsorshipCommand(
Notes = notes
};
if (existingOrgSponsorship != null)
if (!isAdminInitiated)
{
// Replace existing invalid offer with our new sponsorship offer
sponsorship.Id = existingOrgSponsorship.Id;
var existingOrgSponsorship = await organizationSponsorshipRepository
.GetBySponsoringOrganizationUserIdAsync(sponsoringMember.Id);
if (existingOrgSponsorship?.SponsoredOrganizationId != null)
{
throw new BadRequestException("Can only sponsor one organization per Organization User.");
}
if (existingOrgSponsorship != null)
{
// Replace existing invalid offer with our new sponsorship offer
sponsorship.Id = existingOrgSponsorship.Id;
}
}
if (isAdminInitiated && sponsoringOrganization.Seats.HasValue)