1
0
mirror of https://github.com/bitwarden/server.git synced 2025-04-05 13:08:17 -05:00

[PM-13620]Existing user email linking to create-organization (#5315)

* Changes for the existing customer

Signed-off-by: Cy Okeke <cokeke@bitwarden.com>

* removed the added character

Signed-off-by: Cy Okeke <cokeke@bitwarden.com>

---------

Signed-off-by: Cy Okeke <cokeke@bitwarden.com>
This commit is contained in:
cyprain-okeke 2025-02-19 13:13:48 +01:00 committed by GitHub
parent f27886e312
commit fcb9848180
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 20 additions and 8 deletions

View File

@ -5,6 +5,7 @@ namespace Bit.Core.Billing.Models.Mail;
public class TrialInitiationVerifyEmail : RegisterVerifyEmail public class TrialInitiationVerifyEmail : RegisterVerifyEmail
{ {
public bool IsExistingUser { get; set; }
/// <summary> /// <summary>
/// See comment on <see cref="RegisterVerifyEmail"/>.<see cref="RegisterVerifyEmail.Url"/> /// See comment on <see cref="RegisterVerifyEmail"/>.<see cref="RegisterVerifyEmail.Url"/>
/// </summary> /// </summary>
@ -26,8 +27,18 @@ public class TrialInitiationVerifyEmail : RegisterVerifyEmail
/// Currently we only support one product type at a time, despite Product being a collection. /// 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 /// If we receive both PasswordManager and SecretsManager, we'll send the user to the PM trial route
/// </summary> /// </summary>
private string Route => private string Route
Product.Any(p => p == ProductType.PasswordManager) {
get
{
if (IsExistingUser)
{
return "create-organization";
}
return Product.Any(p => p == ProductType.PasswordManager)
? "trial-initiation" ? "trial-initiation"
: "secrets-manager-trial-initiation"; : "secrets-manager-trial-initiation";
}
}
} }

View File

@ -43,10 +43,7 @@ public class SendTrialInitiationEmailForRegistrationCommand(
await PerformConstantTimeOperationsAsync(); await PerformConstantTimeOperationsAsync();
if (!userExists) await mailService.SendTrialInitiationSignupEmailAsync(userExists, email, token, productTier, products);
{
await mailService.SendTrialInitiationSignupEmailAsync(email, token, productTier, products);
}
return null; return null;
} }

View File

@ -14,6 +14,7 @@ public interface IMailService
Task SendVerifyEmailEmailAsync(string email, Guid userId, string token); Task SendVerifyEmailEmailAsync(string email, Guid userId, string token);
Task SendRegistrationVerificationEmailAsync(string email, string token); Task SendRegistrationVerificationEmailAsync(string email, string token);
Task SendTrialInitiationSignupEmailAsync( Task SendTrialInitiationSignupEmailAsync(
bool isExistingUser,
string email, string email,
string token, string token,
ProductTierType productTier, ProductTierType productTier,

View File

@ -74,6 +74,7 @@ public class HandlebarsMailService : IMailService
} }
public async Task SendTrialInitiationSignupEmailAsync( public async Task SendTrialInitiationSignupEmailAsync(
bool isExistingUser,
string email, string email,
string token, string token,
ProductTierType productTier, ProductTierType productTier,
@ -82,6 +83,7 @@ public class HandlebarsMailService : IMailService
var message = CreateDefaultMessage("Verify your email", email); var message = CreateDefaultMessage("Verify your email", email);
var model = new TrialInitiationVerifyEmail var model = new TrialInitiationVerifyEmail
{ {
IsExistingUser = isExistingUser,
Token = WebUtility.UrlEncode(token), Token = WebUtility.UrlEncode(token),
Email = WebUtility.UrlEncode(email), Email = WebUtility.UrlEncode(email),
WebVaultUrl = _globalSettings.BaseServiceUri.VaultWithHash, WebVaultUrl = _globalSettings.BaseServiceUri.VaultWithHash,

View File

@ -26,6 +26,7 @@ public class NoopMailService : IMailService
} }
public Task SendTrialInitiationSignupEmailAsync( public Task SendTrialInitiationSignupEmailAsync(
bool isExistingUser,
string email, string email,
string token, string token,
ProductTierType productTier, ProductTierType productTier,