1
0
mirror of https://github.com/bitwarden/server.git synced 2025-07-12 13:19:01 -05:00

[PM-20084] [PM-20086] Add TrialLength parameter to trial initiation endpoint and email (#5770)

* Add trial length parameter to trial initiation endpoint and email

* Add feature flag that pegs trial length to 7 when disabled

* Add optionality to Identity

* Move feature service injection to identity accounts controller
This commit is contained in:
Alex Morask
2025-05-08 10:43:19 -04:00
committed by GitHub
parent e4a93b24f1
commit c9b6e5de86
13 changed files with 67 additions and 13 deletions

View File

@ -7,4 +7,5 @@ public class TrialSendVerificationEmailRequestModel : RegisterSendVerificationEm
{
public ProductTierType ProductTier { get; set; }
public IEnumerable<ProductType> Products { get; set; }
public int? TrialLength { get; set; }
}

View File

@ -1,5 +1,6 @@
using Bit.Core.Auth.Models.Mail;
using Bit.Core.Billing.Enums;
using Bit.Core.Enums;
namespace Bit.Core.Billing.Models.Mail;
@ -16,13 +17,26 @@ public class TrialInitiationVerifyEmail : RegisterVerifyEmail
$"&email={Email}" +
$"&fromEmail=true" +
$"&productTier={(int)ProductTier}" +
$"&product={string.Join(",", Product.Select(p => (int)p))}";
$"&product={string.Join(",", Product.Select(p => (int)p))}" +
$"&trialLength={TrialLength}";
}
public string VerifyYourEmailHTMLCopy =>
TrialLength == 7
? "Verify your email address below to finish signing up for your free trial."
: $"Verify your email address below to finish signing up for your {ProductTier.GetDisplayName()} plan.";
public string VerifyYourEmailTextCopy =>
TrialLength == 7
? "Verify your email address using the link below and start your free trial of Bitwarden."
: $"Verify your email address using the link below and start your {ProductTier.GetDisplayName()} Bitwarden plan.";
public ProductTierType ProductTier { get; set; }
public IEnumerable<ProductType> Product { get; set; }
public int TrialLength { get; set; }
/// <summary>
/// Currently we only support one product type at a time, despite Product being a collection.
/// If we receive both PasswordManager and SecretsManager, we'll send the user to the PM trial route

View File

@ -10,5 +10,6 @@ public interface ISendTrialInitiationEmailForRegistrationCommand
string? name,
bool receiveMarketingEmails,
ProductTierType productTier,
IEnumerable<ProductType> products);
IEnumerable<ProductType> products,
int trialLength);
}

View File

@ -22,7 +22,8 @@ public class SendTrialInitiationEmailForRegistrationCommand(
string? name,
bool receiveMarketingEmails,
ProductTierType productTier,
IEnumerable<ProductType> products)
IEnumerable<ProductType> products,
int trialLength)
{
ArgumentException.ThrowIfNullOrWhiteSpace(email, nameof(email));
@ -43,7 +44,12 @@ public class SendTrialInitiationEmailForRegistrationCommand(
await PerformConstantTimeOperationsAsync();
await mailService.SendTrialInitiationSignupEmailAsync(userExists, email, token, productTier, products);
if (trialLength != 0 && trialLength != 7)
{
trialLength = 7;
}
await mailService.SendTrialInitiationSignupEmailAsync(userExists, email, token, productTier, products, trialLength);
return null;
}