1
0
mirror of https://github.com/bitwarden/server.git synced 2024-11-21 12:05:42 +01:00

Use accept flow for sponsorship offers (#1964)

This commit is contained in:
Matt Gibson 2022-04-27 12:03:14 -04:00 committed by GitHub
parent 972657f982
commit 68f875b3d9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 29 additions and 44 deletions

View File

@ -1,10 +0,0 @@
namespace Bit.Core.Models.Mail.FamiliesForEnterprise
{
public class FamiliesForEnterpriseOfferExistingAccountViewModel : BaseMailModel
{
public string SponsorEmail { get; set; }
public string SponsoredEmail { get; set; }
public string SponsorshipToken { get; set; }
public string Url => $"{WebVaultUrl}/?sponsorshipToken={SponsorshipToken}&email={SponsoredEmail}";
}
}

View File

@ -1,10 +0,0 @@
namespace Bit.Core.Models.Mail.FamiliesForEnterprise
{
public class FamiliesForEnterpriseOfferNewAccountViewModel : BaseMailModel
{
public string SponsorEmail { get; set; }
public string SponsoredEmail { get; set; }
public string SponsorshipToken { get; set; }
public string Url => $"{WebVaultUrl}/register?sponsorshipToken={SponsorshipToken}&email={SponsoredEmail}";
}
}

View File

@ -0,0 +1,17 @@
namespace Bit.Core.Models.Mail.FamiliesForEnterprise
{
public class FamiliesForEnterpriseOfferViewModel : BaseMailModel
{
public string SponsorEmail { get; set; }
public string SponsoredEmail { get; set; }
public string SponsorshipToken { get; set; }
public bool ExistingAccount { get; set; }
public string Url => string.Concat(
WebVaultUrl,
"/accept-families-for-enterprise",
$"?token={SponsorshipToken}",
$"&email={SponsoredEmail}",
ExistingAccount ? "" : "&register=true"
);
}
}

View File

@ -807,32 +807,20 @@ namespace Bit.Core.Services
{
var message = CreateDefaultMessage("Accept Your Free Families Subscription", email);
if (existingAccount)
var model = new FamiliesForEnterpriseOfferViewModel
{
var model = new FamiliesForEnterpriseOfferExistingAccountViewModel
{
SponsorEmail = CoreHelpers.ObfuscateEmail(sponsorEmail),
SponsoredEmail = WebUtility.UrlEncode(email),
WebVaultUrl = _globalSettings.BaseServiceUri.VaultWithHash,
SiteName = _globalSettings.SiteName,
SponsorshipToken = token,
};
SponsorEmail = CoreHelpers.ObfuscateEmail(sponsorEmail),
SponsoredEmail = WebUtility.UrlEncode(email),
ExistingAccount = existingAccount,
WebVaultUrl = _globalSettings.BaseServiceUri.VaultWithHash,
SiteName = _globalSettings.SiteName,
SponsorshipToken = token,
};
var templateName = existingAccount ?
"FamiliesForEnterprise.FamiliesForEnterpriseOfferExistingAccount" :
"FamiliesForEnterprise.FamiliesForEnterpriseOfferNewAccount";
await AddMessageContentAsync(message, "FamiliesForEnterprise.FamiliesForEnterpriseOfferExistingAccount", model);
}
else
{
var model = new FamiliesForEnterpriseOfferNewAccountViewModel
{
SponsorEmail = sponsorEmail,
SponsoredEmail = WebUtility.UrlEncode(email),
WebVaultUrl = _globalSettings.BaseServiceUri.VaultWithHash,
SiteName = _globalSettings.SiteName,
SponsorshipToken = token,
};
await AddMessageContentAsync(message, "FamiliesForEnterprise.FamiliesForEnterpriseOfferNewAccount", model);
}
await AddMessageContentAsync(message, templateName, model);
message.Category = "FamiliesForEnterpriseOffer";
await _mailDeliveryService.SendEmailAsync(message);