1
0
mirror of https://github.com/bitwarden/server.git synced 2025-07-02 16:42:50 -05:00

[PM-5093][PM-7325] Added trial initiation email verification endpoint (#4221)

* Added trial initiation user verification endpoint

* Added explanatory comment for why we add artificial delay

* Updated RegistrationStart to Registration reference event

* Ensure that productTier query param is an int

* Added email value to trial initiation email
This commit is contained in:
Conner Turnbull
2024-07-29 14:18:12 -04:00
committed by GitHub
parent 2b738a5a4c
commit 656e0c20f9
12 changed files with 266 additions and 1 deletions

View File

@ -0,0 +1,48 @@
using Bit.Core;
using Bit.Core.Billing.Models.Api.Requests.Accounts;
using Bit.Core.Billing.TrialInitiation.Registration;
using Bit.Core.Context;
using Bit.Core.Tools.Enums;
using Bit.Core.Tools.Models.Business;
using Bit.Core.Tools.Services;
using Bit.Core.Utilities;
using Bit.SharedWeb.Utilities;
using Microsoft.AspNetCore.Mvc;
namespace Bit.Identity.Billing.Controller;
[Route("accounts")]
[ExceptionHandlerFilter]
public class AccountsController(
ICurrentContext currentContext,
ISendTrialInitiationEmailForRegistrationCommand sendTrialInitiationEmailForRegistrationCommand,
IReferenceEventService referenceEventService) : Microsoft.AspNetCore.Mvc.Controller
{
[RequireFeature(FeatureFlagKeys.EmailVerification)]
[HttpPost("trial/send-verification-email")]
public async Task<IActionResult> PostTrialInitiationSendVerificationEmailAsync([FromBody] TrialSendVerificationEmailRequestModel model)
{
var token = await sendTrialInitiationEmailForRegistrationCommand.Handle(
model.Email,
model.Name,
model.ReceiveMarketingEmails,
model.ProductTier,
model.Products);
var refEvent = new ReferenceEvent
{
Type = ReferenceEventType.SignupEmailSubmit,
ClientId = currentContext.ClientId,
ClientVersion = currentContext.ClientVersion,
Source = ReferenceEventSource.Registration
};
await referenceEventService.RaiseEventAsync(refEvent);
if (token != null)
{
return Ok(token);
}
return NoContent();
}
}