1
0
mirror of https://github.com/bitwarden/server.git synced 2025-07-01 08:02:49 -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

@ -1,8 +1,6 @@
using System;
using System.Linq;
using System.Threading.Tasks;
using Bit.Core.Context;
using Bit.Core.Enums;
using Bit.Core.Exceptions;
using Bit.Core.Models.Api;
using Bit.Core.Models.Api.Request;
@ -67,11 +65,18 @@ namespace Bit.Api.Controllers
(await CurrentUser).Email);
}
[HttpPost("validate-token")]
[SelfHosted(NotSelfHostedOnly = true)]
public async Task<bool> PreValidateSponsorshipToken([FromQuery] string sponsorshipToken)
{
return await _organizationsSponsorshipService.ValidateRedemptionTokenAsync(sponsorshipToken, (await CurrentUser).Email);
}
[HttpPost("redeem")]
[SelfHosted(NotSelfHostedOnly = true)]
public async Task RedeemSponsorship([FromQuery] string sponsorshipToken, [FromBody] OrganizationSponsorshipRedeemRequestModel model)
{
if (!await _organizationsSponsorshipService.ValidateRedemptionTokenAsync(sponsorshipToken))
if (!await _organizationsSponsorshipService.ValidateRedemptionTokenAsync(sponsorshipToken, (await CurrentUser).Email))
{
throw new BadRequestException("Failed to parse sponsorship token.");
}