1
0
mirror of https://github.com/bitwarden/server.git synced 2025-07-02 00:22: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:
Matt Gibson
2021-11-24 14:18:52 -06:00
committed by GitHub
parent 0ae9e28884
commit 8dffb27667
4 changed files with 41 additions and 13 deletions

View File

@ -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;
}