mirror of
https://github.com/bitwarden/server.git
synced 2025-06-30 23:52:50 -05:00
Families for enterprise/add sponsorship prevalidate (#1734)
* Add sponsorship prevalidate endpoint * Test pre validate endpoint * Fix tests * Rename variable
This commit is contained in:
@ -7,7 +7,7 @@ namespace Bit.Core.Services
|
||||
{
|
||||
public interface IOrganizationSponsorshipService
|
||||
{
|
||||
Task<bool> ValidateRedemptionTokenAsync(string encryptedToken);
|
||||
Task<bool> ValidateRedemptionTokenAsync(string encryptedToken, string currentUserEmail);
|
||||
Task OfferSponsorshipAsync(Organization sponsoringOrg, OrganizationUser sponsoringOrgUser,
|
||||
PlanSponsorshipType sponsorshipType, string sponsoredEmail, string friendlyName, string sponsoringUserEmail);
|
||||
Task ResendSponsorshipOfferAsync(Organization sponsoringOrg, OrganizationUser sponsoringOrgUser,
|
||||
|
@ -37,9 +37,9 @@ namespace Bit.Core.Services
|
||||
_dataProtector = dataProtectionProvider.CreateProtector("OrganizationSponsorshipServiceDataProtector");
|
||||
}
|
||||
|
||||
public async Task<bool> ValidateRedemptionTokenAsync(string encryptedToken)
|
||||
public async Task<bool> ValidateRedemptionTokenAsync(string encryptedToken, string sponsoredUserEmail)
|
||||
{
|
||||
if (!encryptedToken.StartsWith(TokenClearTextPrefix))
|
||||
if (!encryptedToken.StartsWith(TokenClearTextPrefix) || sponsoredUserEmail == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
@ -61,7 +61,9 @@ namespace Bit.Core.Services
|
||||
}
|
||||
|
||||
var sponsorship = await _organizationSponsorshipRepository.GetByIdAsync(sponsorshipId);
|
||||
if (sponsorship == null || sponsorship.PlanSponsorshipType != sponsorshipType)
|
||||
if (sponsorship == null ||
|
||||
sponsorship.PlanSponsorshipType != sponsorshipType ||
|
||||
sponsorship.OfferedToEmail != sponsoredUserEmail)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
Reference in New Issue
Block a user