2022-06-29 19:46:41 -04:00
|
|
|
|
using System.Net;
|
2018-08-03 23:04:47 -04:00
|
|
|
|
using System.Reflection;
|
2023-04-14 13:25:56 -04:00
|
|
|
|
using Bit.Core.Auth.Entities;
|
|
|
|
|
|
using Bit.Core.Auth.Models.Business;
|
|
|
|
|
|
using Bit.Core.Auth.Models.Mail;
|
2022-01-11 10:40:51 +01:00
|
|
|
|
using Bit.Core.Entities;
|
|
|
|
|
|
using Bit.Core.Entities.Provider;
|
2018-08-03 23:04:47 -04:00
|
|
|
|
using Bit.Core.Models.Mail;
|
Families for Enterprise (#1714)
* Create common test infrastructure project
* Add helpers to further type PlanTypes
* Enable testing of ASP.net MVC controllers
Controller properties have all kinds of validations in the background.
In general, we don't user properties on our Controllers, so the easiest
way to allow for Autofixture-based testing of our Controllers is to just
omit setting all properties on them.
* Workaround for broken MemberAutoDataAttribute
https://github.com/AutoFixture/AutoFixture/pull/1164 shows that only
the first test case is pulled for this attribute.
This is a workaround that populates the provided parameters, left to
right, using AutoFixture to populate any remaining.
* WIP: Organization sponsorship flow
* Add Attribute to use the Bit Autodata dependency chain
BitAutoDataAttribute is used to mark a Theory as autopopulating
parameters.
Extract common attribute methods to to a helper class. Cannot
inherit a common base, since both require inheriting from different
Xunit base classes to work.
* WIP: scaffolding for families for enterprise sponsorship flow
* Fix broken tests
* Create sponsorship offer (#1688)
* Initial db work (#1687)
* Add organization sponsorship databases to all providers
* Generalize create and update for database, specialize in code
* Add PlanSponsorshipType to db model
* Write valid json for test entries
* Initial scaffolding of emails (#1686)
* Initial scaffolding of emails
* Work on adding models for FamilyForEnterprise emails
* Switch verbage
* Put preliminary copy in emails
* Skip test
* Families for enterprise/stripe integrations (#1699)
* Add PlanSponsorshipType to static store
* Add sponsorship type to token and creates sponsorship
* PascalCase properties
* Require sponsorship for remove
* Create subscription sponsorship helper class
* Handle Sponsored subscription changes
* Add sponsorship id to subscription metadata
* Make sponsoring references nullable
This state indicates that a sponsorship has lapsed, but was not able to
be reverted for billing reasons
* WIP: Validate and remove subscriptions
* Update sponsorships on organization and org user delete
* Add friendly name to organization sponsorship
* Add sponsorship available boolean to orgDetails
* Add sponsorship service to DI
* Use userId to find org users
* Send f4e offer email
* Simplify names of f4e mail messages
* Fix Stripe org default tax rates
* Universal sponsorship redeem api
* Populate user in current context
* Add product type to organization details
* Use upgrade path to change sponsorship
Sponsorships need to be annual to match the GB add-on charge rate
* Use organization and auth to find organization sponsorship
* Add resend sponsorship offer api endpoint
* Fix double email send
* Fix sponsorship upgrade options
* Add is sponsored item to subscription response
* Add sponsorship validation to upcoming invoice webhook
* Add sponsorship validation to upcoming invoice webhook
* Fix organization delete sponsorship hooks
* Test org sponsorship service
* Fix sproc
* Create common test infrastructure project
* Add helpers to further type PlanTypes
* Enable testing of ASP.net MVC controllers
Controller properties have all kinds of validations in the background.
In general, we don't user properties on our Controllers, so the easiest
way to allow for Autofixture-based testing of our Controllers is to just
omit setting all properties on them.
* Workaround for broken MemberAutoDataAttribute
https://github.com/AutoFixture/AutoFixture/pull/1164 shows that only
the first test case is pulled for this attribute.
This is a workaround that populates the provided parameters, left to
right, using AutoFixture to populate any remaining.
* WIP: Organization sponsorship flow
* Add Attribute to use the Bit Autodata dependency chain
BitAutoDataAttribute is used to mark a Theory as autopopulating
parameters.
Extract common attribute methods to to a helper class. Cannot
inherit a common base, since both require inheriting from different
Xunit base classes to work.
* WIP: scaffolding for families for enterprise sponsorship flow
* Fix broken tests
* Create sponsorship offer (#1688)
* Initial db work (#1687)
* Add organization sponsorship databases to all providers
* Generalize create and update for database, specialize in code
* Add PlanSponsorshipType to db model
* Write valid json for test entries
* Initial scaffolding of emails (#1686)
* Initial scaffolding of emails
* Work on adding models for FamilyForEnterprise emails
* Switch verbage
* Put preliminary copy in emails
* Skip test
* Families for enterprise/stripe integrations (#1699)
* Add PlanSponsorshipType to static store
* Add sponsorship type to token and creates sponsorship
* PascalCase properties
* Require sponsorship for remove
* Create subscription sponsorship helper class
* Handle Sponsored subscription changes
* Add sponsorship id to subscription metadata
* Make sponsoring references nullable
This state indicates that a sponsorship has lapsed, but was not able to
be reverted for billing reasons
* WIP: Validate and remove subscriptions
* Update sponsorships on organization and org user delete
* Add friendly name to organization sponsorship
* Add sponsorship available boolean to orgDetails
* Add sponsorship service to DI
* Use userId to find org users
* Send f4e offer email
* Simplify names of f4e mail messages
* Fix Stripe org default tax rates
* Universal sponsorship redeem api
* Populate user in current context
* Add product type to organization details
* Use upgrade path to change sponsorship
Sponsorships need to be annual to match the GB add-on charge rate
* Use organization and auth to find organization sponsorship
* Add resend sponsorship offer api endpoint
* Fix double email send
* Fix sponsorship upgrade options
* Add is sponsored item to subscription response
* Add sponsorship validation to upcoming invoice webhook
* Add sponsorship validation to upcoming invoice webhook
* Fix organization delete sponsorship hooks
* Test org sponsorship service
* Fix sproc
* Fix build error
* Update emails
* Fix tests
* Skip local test
* Add newline
* Fix stripe subscription update
* Finish emails
* Skip test
* Fix unit tests
* Remove unused variable
* Fix unit tests
* Switch to handlebars ifs
* Remove ending email
* Remove reconfirmation template
* Switch naming convention
* Switch naming convention
* Fix migration
* Update copy and links
* Switch to using Guid in the method
* Remove unneeded css styles
* Add sql files to Sql.sqlproj
* Removed old comments
* Made name more verbose
* Fix SQL error
* Move unit tests to service
* Fix sp
* Revert "Move unit tests to service"
This reverts commit 1185bf3ec8ca36ccd75717ed2463adf8885159a6.
* Do repository validation in service layer
* Fix tests
* Fix merge conflicts and remove TODO
* Remove unneeded models
* Fix spacing and formatting
* Switch Org -> Organization
* Remove single use variables
* Switch method name
* Fix Controller
* Switch to obfuscating email
* Fix unit tests
Co-authored-by: Justin Baur <admin@justinbaur.com>
2021-11-19 16:25:06 -06:00
|
|
|
|
using Bit.Core.Models.Mail.FamiliesForEnterprise;
|
2021-06-03 18:58:29 +02:00
|
|
|
|
using Bit.Core.Models.Mail.Provider;
|
2021-02-22 15:35:16 -06:00
|
|
|
|
using Bit.Core.Settings;
|
2018-08-03 23:04:47 -04:00
|
|
|
|
using Bit.Core.Utilities;
|
|
|
|
|
|
using HandlebarsDotNet;
|
|
|
|
|
|
|
|
|
|
|
|
namespace Bit.Core.Services;
|
2022-08-29 16:06:55 -04:00
|
|
|
|
|
2018-08-03 23:04:47 -04:00
|
|
|
|
public class HandlebarsMailService : IMailService
|
|
|
|
|
|
{
|
|
|
|
|
|
private const string Namespace = "Bit.Core.MailTemplates.Handlebars";
|
[AC-1191] TDE admin approval email (#3044)
* feat: add new command for updating request and emailing user, refs AC-1191
* feat: inject service with organization service collection extensions, refs AC-1191
* feat: add function to send admin approval email to mail services (interface/noop/handlebars), refs AC-1191
* feat: add html/text mail templates and add view model for email data, refs AC-1191
* feat: update org auth request controller to use new command during auth request update, refs AC-1191
* fix: dotnet format, refs AC-1191
* refactor: update user not found error, FirstOrDefault for enum type display name, refs AC-1191
* refactor: update user not found to log error instead of throws, refs AC-1191
* fix: remove whitespace lint errors, refs AC-1191
* refactor: update hardcoded UTC timezone string, refs AC-1191
* refactor: add unit test for new command, refs AC-1191
* refactor: improve enum name fallback and identifier string creation, refs AC-1191
* refactor: add addtional unit tests, refs AC-1191
* refactor: update success test to use more generated params, refs AC-1191
* fix: dotnet format...again, refs AC-1191
* refactor: make UTC display a constant for handlebars mail service, refs AC-1191
* refactor: update displayTypeIdentifer to displayTypeAndIdentifier for clarity, refs AC-1191
2023-07-06 10:03:49 -05:00
|
|
|
|
private const string _utcTimeZoneDisplay = "UTC";
|
2022-08-29 16:06:55 -04:00
|
|
|
|
|
2018-08-03 23:04:47 -04:00
|
|
|
|
private readonly GlobalSettings _globalSettings;
|
|
|
|
|
|
private readonly IMailDeliveryService _mailDeliveryService;
|
|
|
|
|
|
private readonly IMailEnqueuingService _mailEnqueuingService;
|
2022-06-24 10:39:34 -04:00
|
|
|
|
private readonly Dictionary<string, HandlebarsTemplate<object, object>> _templateCache =
|
2018-08-03 23:04:47 -04:00
|
|
|
|
new Dictionary<string, HandlebarsTemplate<object, object>>();
|
2022-08-29 16:06:55 -04:00
|
|
|
|
|
2018-08-03 23:04:47 -04:00
|
|
|
|
private bool _registeredHelpersAndPartials = false;
|
2022-08-29 16:06:55 -04:00
|
|
|
|
|
2018-08-03 23:04:47 -04:00
|
|
|
|
public HandlebarsMailService(
|
2021-05-17 09:43:02 -05:00
|
|
|
|
GlobalSettings globalSettings,
|
|
|
|
|
|
IMailDeliveryService mailDeliveryService,
|
|
|
|
|
|
IMailEnqueuingService mailEnqueuingService)
|
2018-08-03 23:04:47 -04:00
|
|
|
|
{
|
|
|
|
|
|
_globalSettings = globalSettings;
|
|
|
|
|
|
_mailDeliveryService = mailDeliveryService;
|
|
|
|
|
|
_mailEnqueuingService = mailEnqueuingService;
|
2022-08-29 16:06:55 -04:00
|
|
|
|
}
|
2018-08-03 23:04:47 -04:00
|
|
|
|
|
|
|
|
|
|
public async Task SendVerifyEmailEmailAsync(string email, Guid userId, string token)
|
2022-08-29 16:06:55 -04:00
|
|
|
|
{
|
2018-08-03 23:04:47 -04:00
|
|
|
|
var message = CreateDefaultMessage("Verify Your Email", email);
|
|
|
|
|
|
var model = new VerifyEmailModel
|
2022-08-29 16:06:55 -04:00
|
|
|
|
{
|
2018-08-03 23:04:47 -04:00
|
|
|
|
Token = WebUtility.UrlEncode(token),
|
|
|
|
|
|
UserId = userId,
|
|
|
|
|
|
WebVaultUrl = _globalSettings.BaseServiceUri.VaultWithHash,
|
|
|
|
|
|
SiteName = _globalSettings.SiteName
|
2022-08-29 16:06:55 -04:00
|
|
|
|
};
|
2023-04-14 13:25:56 -04:00
|
|
|
|
await AddMessageContentAsync(message, "Auth.VerifyEmail", model);
|
2018-08-03 23:04:47 -04:00
|
|
|
|
message.MetaData.Add("SendGridBypassListManagement", true);
|
|
|
|
|
|
message.Category = "VerifyEmail";
|
|
|
|
|
|
await _mailDeliveryService.SendEmailAsync(message);
|
2022-08-29 16:06:55 -04:00
|
|
|
|
}
|
2018-08-03 23:04:47 -04:00
|
|
|
|
|
|
|
|
|
|
public async Task SendVerifyDeleteEmailAsync(string email, Guid userId, string token)
|
2022-08-29 16:06:55 -04:00
|
|
|
|
{
|
2018-08-03 23:04:47 -04:00
|
|
|
|
var message = CreateDefaultMessage("Delete Your Account", email);
|
|
|
|
|
|
var model = new VerifyDeleteModel
|
2022-08-29 16:06:55 -04:00
|
|
|
|
{
|
2018-08-03 23:04:47 -04:00
|
|
|
|
Token = WebUtility.UrlEncode(token),
|
|
|
|
|
|
UserId = userId,
|
|
|
|
|
|
WebVaultUrl = _globalSettings.BaseServiceUri.VaultWithHash,
|
|
|
|
|
|
SiteName = _globalSettings.SiteName,
|
|
|
|
|
|
Email = email,
|
|
|
|
|
|
EmailEncoded = WebUtility.UrlEncode(email)
|
2022-08-29 16:06:55 -04:00
|
|
|
|
};
|
2023-04-14 13:25:56 -04:00
|
|
|
|
await AddMessageContentAsync(message, "Auth.VerifyDelete", model);
|
2018-08-03 23:04:47 -04:00
|
|
|
|
message.MetaData.Add("SendGridBypassListManagement", true);
|
|
|
|
|
|
message.Category = "VerifyDelete";
|
|
|
|
|
|
await _mailDeliveryService.SendEmailAsync(message);
|
2022-08-29 16:06:55 -04:00
|
|
|
|
}
|
2018-08-03 23:04:47 -04:00
|
|
|
|
|
2021-05-17 09:43:02 -05:00
|
|
|
|
public async Task SendChangeEmailAlreadyExistsEmailAsync(string fromEmail, string toEmail)
|
2022-08-29 16:06:55 -04:00
|
|
|
|
{
|
2021-05-17 09:43:02 -05:00
|
|
|
|
var message = CreateDefaultMessage("Your Email Change", toEmail);
|
|
|
|
|
|
var model = new ChangeEmailExistsViewModel
|
2018-08-03 23:04:47 -04:00
|
|
|
|
{
|
|
|
|
|
|
FromEmail = fromEmail,
|
|
|
|
|
|
ToEmail = toEmail,
|
|
|
|
|
|
WebVaultUrl = _globalSettings.BaseServiceUri.VaultWithHash,
|
|
|
|
|
|
SiteName = _globalSettings.SiteName
|
|
|
|
|
|
};
|
|
|
|
|
|
await AddMessageContentAsync(message, "ChangeEmailAlreadyExists", model);
|
|
|
|
|
|
message.Category = "ChangeEmailAlreadyExists";
|
|
|
|
|
|
await _mailDeliveryService.SendEmailAsync(message);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public async Task SendChangeEmailEmailAsync(string newEmailAddress, string token)
|
|
|
|
|
|
{
|
|
|
|
|
|
var message = CreateDefaultMessage("Your Email Change", newEmailAddress);
|
|
|
|
|
|
var model = new EmailTokenViewModel
|
|
|
|
|
|
{
|
|
|
|
|
|
Token = token,
|
|
|
|
|
|
WebVaultUrl = _globalSettings.BaseServiceUri.VaultWithHash,
|
|
|
|
|
|
SiteName = _globalSettings.SiteName
|
|
|
|
|
|
};
|
|
|
|
|
|
await AddMessageContentAsync(message, "ChangeEmail", model);
|
|
|
|
|
|
message.MetaData.Add("SendGridBypassListManagement", true);
|
2019-03-13 16:19:00 -04:00
|
|
|
|
message.Category = "ChangeEmail";
|
2018-08-03 23:04:47 -04:00
|
|
|
|
await _mailDeliveryService.SendEmailAsync(message);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public async Task SendTwoFactorEmailAsync(string email, string token)
|
|
|
|
|
|
{
|
|
|
|
|
|
var message = CreateDefaultMessage("Your Two-step Login Verification Code", email);
|
|
|
|
|
|
var model = new EmailTokenViewModel
|
|
|
|
|
|
{
|
|
|
|
|
|
Token = token,
|
|
|
|
|
|
WebVaultUrl = _globalSettings.BaseServiceUri.VaultWithHash,
|
|
|
|
|
|
SiteName = _globalSettings.SiteName
|
2022-08-29 15:53:48 -04:00
|
|
|
|
};
|
2023-04-14 13:25:56 -04:00
|
|
|
|
await AddMessageContentAsync(message, "Auth.TwoFactorEmail", model);
|
2018-08-03 23:04:47 -04:00
|
|
|
|
message.MetaData.Add("SendGridBypassListManagement", true);
|
2019-03-13 16:19:00 -04:00
|
|
|
|
message.Category = "TwoFactorEmail";
|
2018-08-03 23:04:47 -04:00
|
|
|
|
await _mailDeliveryService.SendEmailAsync(message);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public async Task SendMasterPasswordHintEmailAsync(string email, string hint)
|
|
|
|
|
|
{
|
|
|
|
|
|
var message = CreateDefaultMessage("Your Master Password Hint", email);
|
|
|
|
|
|
var model = new MasterPasswordHintViewModel
|
|
|
|
|
|
{
|
|
|
|
|
|
Hint = CoreHelpers.SanitizeForEmail(hint, false),
|
|
|
|
|
|
WebVaultUrl = _globalSettings.BaseServiceUri.VaultWithHash,
|
|
|
|
|
|
SiteName = _globalSettings.SiteName
|
|
|
|
|
|
};
|
2023-04-14 13:25:56 -04:00
|
|
|
|
await AddMessageContentAsync(message, "Auth.MasterPasswordHint", model);
|
2019-03-13 16:19:00 -04:00
|
|
|
|
message.Category = "MasterPasswordHint";
|
2018-08-03 23:04:47 -04:00
|
|
|
|
await _mailDeliveryService.SendEmailAsync(message);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public async Task SendNoMasterPasswordHintEmailAsync(string email)
|
|
|
|
|
|
{
|
|
|
|
|
|
var message = CreateDefaultMessage("Your Master Password Hint", email);
|
|
|
|
|
|
var model = new BaseMailModel
|
|
|
|
|
|
{
|
|
|
|
|
|
WebVaultUrl = _globalSettings.BaseServiceUri.VaultWithHash,
|
|
|
|
|
|
SiteName = _globalSettings.SiteName
|
|
|
|
|
|
};
|
2023-04-14 13:25:56 -04:00
|
|
|
|
await AddMessageContentAsync(message, "Auth.NoMasterPasswordHint", model);
|
2019-03-13 16:19:00 -04:00
|
|
|
|
message.Category = "NoMasterPasswordHint";
|
2018-08-03 23:04:47 -04:00
|
|
|
|
await _mailDeliveryService.SendEmailAsync(message);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2022-04-01 17:08:47 -03:00
|
|
|
|
public async Task SendOrganizationAutoscaledEmailAsync(Organization organization, int initialSeatCount, IEnumerable<string> ownerEmails)
|
2022-08-29 16:06:55 -04:00
|
|
|
|
{
|
2022-04-01 17:08:47 -03:00
|
|
|
|
var message = CreateDefaultMessage($"{organization.Name} Seat Count Has Increased", ownerEmails);
|
|
|
|
|
|
var model = new OrganizationSeatsAutoscaledViewModel
|
|
|
|
|
|
{
|
2021-09-23 06:36:08 -04:00
|
|
|
|
OrganizationId = organization.Id,
|
2022-04-01 17:08:47 -03:00
|
|
|
|
InitialSeatCount = initialSeatCount,
|
|
|
|
|
|
CurrentSeatCount = organization.Seats.Value,
|
2022-08-29 15:53:48 -04:00
|
|
|
|
};
|
2022-04-01 17:08:47 -03:00
|
|
|
|
|
2018-08-03 23:04:47 -04:00
|
|
|
|
await AddMessageContentAsync(message, "OrganizationSeatsAutoscaled", model);
|
2019-03-13 16:19:00 -04:00
|
|
|
|
message.Category = "OrganizationSeatsAutoscaled";
|
2018-08-03 23:04:47 -04:00
|
|
|
|
await _mailDeliveryService.SendEmailAsync(message);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public async Task SendOrganizationMaxSeatLimitReachedEmailAsync(Organization organization, int maxSeatCount, IEnumerable<string> ownerEmails)
|
2022-08-29 16:06:55 -04:00
|
|
|
|
{
|
2018-08-03 23:04:47 -04:00
|
|
|
|
var message = CreateDefaultMessage($"{organization.Name} Seat Limit Reached", ownerEmails);
|
2021-09-23 06:36:08 -04:00
|
|
|
|
var model = new OrganizationSeatsMaxReachedViewModel
|
2018-08-03 23:04:47 -04:00
|
|
|
|
{
|
|
|
|
|
|
OrganizationId = organization.Id,
|
|
|
|
|
|
MaxSeatCount = maxSeatCount,
|
|
|
|
|
|
};
|
|
|
|
|
|
|
2021-09-23 06:36:08 -04:00
|
|
|
|
await AddMessageContentAsync(message, "OrganizationSeatsMaxReached", model);
|
|
|
|
|
|
message.Category = "OrganizationSeatsMaxReached";
|
|
|
|
|
|
await _mailDeliveryService.SendEmailAsync(message);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2021-07-16 13:49:27 -04:00
|
|
|
|
public async Task SendOrganizationAcceptedEmailAsync(Organization organization, string userIdentifier,
|
2021-09-23 06:36:08 -04:00
|
|
|
|
IEnumerable<string> adminEmails)
|
2022-08-29 16:06:55 -04:00
|
|
|
|
{
|
2021-09-23 06:36:08 -04:00
|
|
|
|
var message = CreateDefaultMessage($"Action Required: {userIdentifier} Needs to Be Confirmed", adminEmails);
|
2018-08-03 23:04:47 -04:00
|
|
|
|
var model = new OrganizationUserAcceptedViewModel
|
2022-08-29 16:06:55 -04:00
|
|
|
|
{
|
2021-07-16 13:49:27 -04:00
|
|
|
|
OrganizationId = organization.Id,
|
2021-09-23 06:36:08 -04:00
|
|
|
|
OrganizationName = CoreHelpers.SanitizeForEmail(organization.Name, false),
|
2021-07-16 13:49:27 -04:00
|
|
|
|
UserIdentifier = userIdentifier,
|
2018-08-03 23:04:47 -04:00
|
|
|
|
WebVaultUrl = _globalSettings.BaseServiceUri.VaultWithHash,
|
|
|
|
|
|
SiteName = _globalSettings.SiteName
|
2022-08-29 16:06:55 -04:00
|
|
|
|
};
|
2021-09-23 06:36:08 -04:00
|
|
|
|
await AddMessageContentAsync(message, "OrganizationUserAccepted", model);
|
|
|
|
|
|
message.Category = "OrganizationUserAccepted";
|
|
|
|
|
|
await _mailDeliveryService.SendEmailAsync(message);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public async Task SendOrganizationConfirmedEmailAsync(string organizationName, string email)
|
|
|
|
|
|
{
|
|
|
|
|
|
var message = CreateDefaultMessage($"You Have Been Confirmed To {organizationName}", email);
|
|
|
|
|
|
var model = new OrganizationUserConfirmedViewModel
|
|
|
|
|
|
{
|
2023-03-21 14:44:58 +00:00
|
|
|
|
TitleFirst = "You're confirmed as a member of ",
|
|
|
|
|
|
TitleSecondBold = CoreHelpers.SanitizeForEmail(organizationName, false),
|
|
|
|
|
|
TitleThird = "!",
|
2021-09-23 06:36:08 -04:00
|
|
|
|
OrganizationName = CoreHelpers.SanitizeForEmail(organizationName, false),
|
|
|
|
|
|
WebVaultUrl = _globalSettings.BaseServiceUri.VaultWithHash,
|
2018-08-03 23:04:47 -04:00
|
|
|
|
SiteName = _globalSettings.SiteName
|
2022-08-29 16:06:55 -04:00
|
|
|
|
};
|
2021-09-23 06:36:08 -04:00
|
|
|
|
await AddMessageContentAsync(message, "OrganizationUserConfirmed", model);
|
|
|
|
|
|
message.Category = "OrganizationUserConfirmed";
|
|
|
|
|
|
await _mailDeliveryService.SendEmailAsync(message);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2023-04-14 11:13:16 +01:00
|
|
|
|
public Task SendOrganizationInviteEmailAsync(string organizationName, OrganizationUser orgUser, ExpiringToken token, bool isFreeOrg, bool initOrganization = false) =>
|
|
|
|
|
|
BulkSendOrganizationInviteEmailAsync(organizationName, new[] { (orgUser, token) }, isFreeOrg, initOrganization);
|
2021-09-23 06:36:08 -04:00
|
|
|
|
|
2023-04-14 11:13:16 +01:00
|
|
|
|
public async Task BulkSendOrganizationInviteEmailAsync(string organizationName, IEnumerable<(OrganizationUser orgUser, ExpiringToken token)> invites, bool isFreeOrg, bool initOrganization = false)
|
2022-08-29 16:06:55 -04:00
|
|
|
|
{
|
2021-07-16 13:49:27 -04:00
|
|
|
|
MailQueueMessage CreateMessage(string email, object model)
|
2018-08-03 23:04:47 -04:00
|
|
|
|
{
|
2021-07-16 13:49:27 -04:00
|
|
|
|
var message = CreateDefaultMessage($"Join {organizationName}", email);
|
2018-08-03 23:04:47 -04:00
|
|
|
|
return new MailQueueMessage(message, "OrganizationUserInvited", model);
|
|
|
|
|
|
}
|
2023-03-21 14:44:58 +00:00
|
|
|
|
var freeOrgTitle = "A Bitwarden member invited you to an organization. Join now to start securing your passwords!";
|
2018-08-03 23:04:47 -04:00
|
|
|
|
var messageModels = invites.Select(invite => CreateMessage(invite.orgUser.Email,
|
|
|
|
|
|
new OrganizationUserInvitedViewModel
|
|
|
|
|
|
{
|
2023-03-21 14:44:58 +00:00
|
|
|
|
TitleFirst = isFreeOrg ? freeOrgTitle : "Join ",
|
|
|
|
|
|
TitleSecondBold = isFreeOrg ? string.Empty : CoreHelpers.SanitizeForEmail(organizationName, false),
|
|
|
|
|
|
TitleThird = isFreeOrg ? string.Empty : " on Bitwarden and start securing your passwords!",
|
|
|
|
|
|
OrganizationName = CoreHelpers.SanitizeForEmail(organizationName, false) + invite.orgUser.Status,
|
2021-05-17 09:43:02 -05:00
|
|
|
|
Email = WebUtility.UrlEncode(invite.orgUser.Email),
|
|
|
|
|
|
OrganizationId = invite.orgUser.OrganizationId.ToString(),
|
|
|
|
|
|
OrganizationUserId = invite.orgUser.Id.ToString(),
|
2021-07-16 14:17:24 -04:00
|
|
|
|
Token = WebUtility.UrlEncode(invite.token.Token),
|
2022-08-29 14:53:16 -04:00
|
|
|
|
ExpirationDate = $"{invite.token.ExpirationDate.ToLongDateString()} {invite.token.ExpirationDate.ToShortTimeString()} UTC",
|
2021-05-17 09:43:02 -05:00
|
|
|
|
OrganizationNameUrlEncoded = WebUtility.UrlEncode(organizationName),
|
2018-08-03 23:04:47 -04:00
|
|
|
|
WebVaultUrl = _globalSettings.BaseServiceUri.VaultWithHash,
|
|
|
|
|
|
SiteName = _globalSettings.SiteName,
|
2023-04-14 11:13:16 +01:00
|
|
|
|
InitOrganization = initOrganization
|
2022-08-29 14:53:16 -04:00
|
|
|
|
}
|
2022-08-29 16:06:55 -04:00
|
|
|
|
));
|
2022-08-29 14:53:16 -04:00
|
|
|
|
|
2018-08-03 23:04:47 -04:00
|
|
|
|
await EnqueueMailAsync(messageModels);
|
|
|
|
|
|
}
|
2022-08-29 14:53:16 -04:00
|
|
|
|
|
2022-05-10 17:12:09 -04:00
|
|
|
|
public async Task SendOrganizationUserRemovedForPolicyTwoStepEmailAsync(string organizationName, string email)
|
2022-08-29 16:06:55 -04:00
|
|
|
|
{
|
2022-05-10 17:12:09 -04:00
|
|
|
|
var message = CreateDefaultMessage($"You have been removed from {organizationName}", email);
|
|
|
|
|
|
var model = new OrganizationUserRemovedForPolicyTwoStepViewModel
|
2022-08-29 16:06:55 -04:00
|
|
|
|
{
|
2022-05-10 17:12:09 -04:00
|
|
|
|
OrganizationName = CoreHelpers.SanitizeForEmail(organizationName, false),
|
|
|
|
|
|
WebVaultUrl = _globalSettings.BaseServiceUri.VaultWithHash,
|
2020-02-27 09:30:04 -05:00
|
|
|
|
SiteName = _globalSettings.SiteName
|
2022-08-29 16:06:55 -04:00
|
|
|
|
};
|
2018-08-03 23:04:47 -04:00
|
|
|
|
await AddMessageContentAsync(message, "OrganizationUserRemovedForPolicyTwoStep", model);
|
2019-03-13 16:19:00 -04:00
|
|
|
|
message.Category = "OrganizationUserRemovedForPolicyTwoStep";
|
2018-08-03 23:04:47 -04:00
|
|
|
|
await _mailDeliveryService.SendEmailAsync(message);
|
2022-08-29 16:06:55 -04:00
|
|
|
|
}
|
|
|
|
|
|
|
2018-08-03 23:04:47 -04:00
|
|
|
|
public async Task SendWelcomeEmailAsync(User user)
|
2022-08-29 16:06:55 -04:00
|
|
|
|
{
|
2022-05-10 17:12:09 -04:00
|
|
|
|
var message = CreateDefaultMessage("Welcome to Bitwarden!", user.Email);
|
2018-08-03 23:04:47 -04:00
|
|
|
|
var model = new BaseMailModel
|
2022-08-29 16:06:55 -04:00
|
|
|
|
{
|
2018-08-03 23:04:47 -04:00
|
|
|
|
WebVaultUrl = _globalSettings.BaseServiceUri.VaultWithHash,
|
|
|
|
|
|
SiteName = _globalSettings.SiteName
|
2022-08-29 16:06:55 -04:00
|
|
|
|
};
|
2018-08-03 23:04:47 -04:00
|
|
|
|
await AddMessageContentAsync(message, "Welcome", model);
|
2019-03-13 16:19:00 -04:00
|
|
|
|
message.Category = "Welcome";
|
2018-08-03 23:04:47 -04:00
|
|
|
|
await _mailDeliveryService.SendEmailAsync(message);
|
2022-08-29 16:06:55 -04:00
|
|
|
|
}
|
|
|
|
|
|
|
2022-05-10 17:12:09 -04:00
|
|
|
|
public async Task SendPasswordlessSignInAsync(string returnUrl, string token, string email)
|
2021-05-17 09:43:02 -05:00
|
|
|
|
{
|
|
|
|
|
|
var message = CreateDefaultMessage("[Admin] Continue Logging In", email);
|
|
|
|
|
|
var url = CoreHelpers.ExtendQuery(new Uri($"{_globalSettings.BaseServiceUri.Admin}/login/confirm"),
|
|
|
|
|
|
new Dictionary<string, string>
|
2022-08-29 14:53:16 -04:00
|
|
|
|
{
|
2021-05-17 09:43:02 -05:00
|
|
|
|
["returnUrl"] = returnUrl,
|
|
|
|
|
|
["email"] = email,
|
2018-08-03 23:04:47 -04:00
|
|
|
|
["token"] = token,
|
2021-05-17 09:43:02 -05:00
|
|
|
|
});
|
|
|
|
|
|
var model = new PasswordlessSignInModel
|
|
|
|
|
|
{
|
2018-08-03 23:04:47 -04:00
|
|
|
|
Url = url.ToString()
|
2022-08-29 16:06:55 -04:00
|
|
|
|
};
|
2023-04-14 13:25:56 -04:00
|
|
|
|
await AddMessageContentAsync(message, "Auth.PasswordlessSignIn", model);
|
2018-08-03 23:04:47 -04:00
|
|
|
|
message.Category = "PasswordlessSignIn";
|
|
|
|
|
|
await _mailDeliveryService.SendEmailAsync(message);
|
2022-08-29 14:53:16 -04:00
|
|
|
|
}
|
2021-05-17 09:43:02 -05:00
|
|
|
|
|
2019-02-14 11:49:39 -05:00
|
|
|
|
public async Task SendInvoiceUpcomingAsync(string email, decimal amount, DateTime dueDate,
|
|
|
|
|
|
List<string> items, bool mentionInvoices)
|
2022-08-29 16:06:55 -04:00
|
|
|
|
{
|
2019-02-14 11:49:39 -05:00
|
|
|
|
var message = CreateDefaultMessage("Your Subscription Will Renew Soon", email);
|
2021-05-17 09:43:02 -05:00
|
|
|
|
var model = new InvoiceUpcomingViewModel
|
2022-08-29 15:53:48 -04:00
|
|
|
|
{
|
2021-05-17 09:43:02 -05:00
|
|
|
|
WebVaultUrl = _globalSettings.BaseServiceUri.VaultWithHash,
|
2019-02-14 11:49:39 -05:00
|
|
|
|
SiteName = _globalSettings.SiteName,
|
|
|
|
|
|
AmountDue = amount,
|
|
|
|
|
|
DueDate = dueDate,
|
|
|
|
|
|
Items = items,
|
|
|
|
|
|
MentionInvoices = mentionInvoices
|
2018-08-03 23:04:47 -04:00
|
|
|
|
};
|
2019-02-14 11:49:39 -05:00
|
|
|
|
await AddMessageContentAsync(message, "InvoiceUpcoming", model);
|
2019-03-13 16:19:00 -04:00
|
|
|
|
message.Category = "InvoiceUpcoming";
|
2022-08-29 15:53:48 -04:00
|
|
|
|
await _mailDeliveryService.SendEmailAsync(message);
|
2022-08-29 16:06:55 -04:00
|
|
|
|
}
|
2018-08-03 23:04:47 -04:00
|
|
|
|
|
2020-02-27 09:30:04 -05:00
|
|
|
|
public async Task SendPaymentFailedAsync(string email, decimal amount, bool mentionInvoices)
|
2022-08-29 16:06:55 -04:00
|
|
|
|
{
|
2019-02-22 21:13:34 -05:00
|
|
|
|
var message = CreateDefaultMessage("Payment Failed", email);
|
2020-02-27 09:30:04 -05:00
|
|
|
|
var model = new PaymentFailedViewModel
|
2022-08-29 16:06:55 -04:00
|
|
|
|
{
|
2020-02-27 09:30:04 -05:00
|
|
|
|
WebVaultUrl = _globalSettings.BaseServiceUri.VaultWithHash,
|
2019-02-22 21:13:34 -05:00
|
|
|
|
SiteName = _globalSettings.SiteName,
|
|
|
|
|
|
Amount = amount,
|
|
|
|
|
|
MentionInvoices = mentionInvoices
|
2022-08-29 16:06:55 -04:00
|
|
|
|
};
|
2019-02-22 21:13:34 -05:00
|
|
|
|
await AddMessageContentAsync(message, "PaymentFailed", model);
|
|
|
|
|
|
message.Category = "PaymentFailed";
|
2020-02-27 09:30:04 -05:00
|
|
|
|
await _mailDeliveryService.SendEmailAsync(message);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2018-08-03 23:04:47 -04:00
|
|
|
|
public async Task SendAddedCreditAsync(string email, decimal amount)
|
|
|
|
|
|
{
|
2021-01-21 14:57:13 -06:00
|
|
|
|
var message = CreateDefaultMessage("Account Credit Payment Processed", email);
|
2018-08-03 23:04:47 -04:00
|
|
|
|
var model = new AddedCreditViewModel
|
|
|
|
|
|
{
|
2022-05-10 17:12:09 -04:00
|
|
|
|
WebVaultUrl = _globalSettings.BaseServiceUri.VaultWithHash,
|
2020-02-27 09:30:04 -05:00
|
|
|
|
SiteName = _globalSettings.SiteName,
|
2019-02-22 21:13:34 -05:00
|
|
|
|
Amount = amount
|
2018-08-03 23:04:47 -04:00
|
|
|
|
};
|
|
|
|
|
|
await AddMessageContentAsync(message, "AddedCredit", model);
|
2019-03-13 16:19:00 -04:00
|
|
|
|
message.Category = "AddedCredit";
|
2018-08-03 23:04:47 -04:00
|
|
|
|
await _mailDeliveryService.SendEmailAsync(message);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public async Task SendLicenseExpiredAsync(IEnumerable<string> emails, string organizationName = null)
|
|
|
|
|
|
{
|
|
|
|
|
|
var message = CreateDefaultMessage("License Expired", emails);
|
|
|
|
|
|
var model = new LicenseExpiredViewModel
|
2022-08-29 14:53:16 -04:00
|
|
|
|
{
|
2018-08-03 23:04:47 -04:00
|
|
|
|
OrganizationName = CoreHelpers.SanitizeForEmail(organizationName, false),
|
|
|
|
|
|
};
|
|
|
|
|
|
await AddMessageContentAsync(message, "LicenseExpired", model);
|
2019-03-13 16:19:00 -04:00
|
|
|
|
message.Category = "LicenseExpired";
|
2018-08-03 23:04:47 -04:00
|
|
|
|
await _mailDeliveryService.SendEmailAsync(message);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public async Task SendNewDeviceLoggedInEmail(string email, string deviceType, DateTime timestamp, string ip)
|
|
|
|
|
|
{
|
|
|
|
|
|
var message = CreateDefaultMessage($"New Device Logged In From {deviceType}", email);
|
|
|
|
|
|
var model = new NewDeviceLoggedInModel
|
2022-08-29 16:06:55 -04:00
|
|
|
|
{
|
2018-08-03 23:04:47 -04:00
|
|
|
|
WebVaultUrl = _globalSettings.BaseServiceUri.VaultWithHash,
|
|
|
|
|
|
SiteName = _globalSettings.SiteName,
|
|
|
|
|
|
DeviceType = deviceType,
|
|
|
|
|
|
TheDate = timestamp.ToLongDateString(),
|
|
|
|
|
|
TheTime = timestamp.ToShortTimeString(),
|
[AC-1191] TDE admin approval email (#3044)
* feat: add new command for updating request and emailing user, refs AC-1191
* feat: inject service with organization service collection extensions, refs AC-1191
* feat: add function to send admin approval email to mail services (interface/noop/handlebars), refs AC-1191
* feat: add html/text mail templates and add view model for email data, refs AC-1191
* feat: update org auth request controller to use new command during auth request update, refs AC-1191
* fix: dotnet format, refs AC-1191
* refactor: update user not found error, FirstOrDefault for enum type display name, refs AC-1191
* refactor: update user not found to log error instead of throws, refs AC-1191
* fix: remove whitespace lint errors, refs AC-1191
* refactor: update hardcoded UTC timezone string, refs AC-1191
* refactor: add unit test for new command, refs AC-1191
* refactor: improve enum name fallback and identifier string creation, refs AC-1191
* refactor: add addtional unit tests, refs AC-1191
* refactor: update success test to use more generated params, refs AC-1191
* fix: dotnet format...again, refs AC-1191
* refactor: make UTC display a constant for handlebars mail service, refs AC-1191
* refactor: update displayTypeIdentifer to displayTypeAndIdentifier for clarity, refs AC-1191
2023-07-06 10:03:49 -05:00
|
|
|
|
TimeZone = _utcTimeZoneDisplay,
|
2019-01-24 22:37:49 -05:00
|
|
|
|
IpAddress = ip
|
2018-08-03 23:04:47 -04:00
|
|
|
|
};
|
|
|
|
|
|
await AddMessageContentAsync(message, "NewDeviceLoggedIn", model);
|
2019-03-13 16:19:00 -04:00
|
|
|
|
message.Category = "NewDeviceLoggedIn";
|
2018-08-03 23:04:47 -04:00
|
|
|
|
await _mailDeliveryService.SendEmailAsync(message);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2019-02-14 11:49:39 -05:00
|
|
|
|
public async Task SendRecoverTwoFactorEmail(string email, DateTime timestamp, string ip)
|
|
|
|
|
|
{
|
|
|
|
|
|
var message = CreateDefaultMessage($"Recover 2FA From {ip}", email);
|
|
|
|
|
|
var model = new RecoverTwoFactorModel
|
2022-08-29 14:53:16 -04:00
|
|
|
|
{
|
2019-02-14 11:49:39 -05:00
|
|
|
|
WebVaultUrl = _globalSettings.BaseServiceUri.VaultWithHash,
|
|
|
|
|
|
SiteName = _globalSettings.SiteName,
|
|
|
|
|
|
TheDate = timestamp.ToLongDateString(),
|
|
|
|
|
|
TheTime = timestamp.ToShortTimeString(),
|
[AC-1191] TDE admin approval email (#3044)
* feat: add new command for updating request and emailing user, refs AC-1191
* feat: inject service with organization service collection extensions, refs AC-1191
* feat: add function to send admin approval email to mail services (interface/noop/handlebars), refs AC-1191
* feat: add html/text mail templates and add view model for email data, refs AC-1191
* feat: update org auth request controller to use new command during auth request update, refs AC-1191
* fix: dotnet format, refs AC-1191
* refactor: update user not found error, FirstOrDefault for enum type display name, refs AC-1191
* refactor: update user not found to log error instead of throws, refs AC-1191
* fix: remove whitespace lint errors, refs AC-1191
* refactor: update hardcoded UTC timezone string, refs AC-1191
* refactor: add unit test for new command, refs AC-1191
* refactor: improve enum name fallback and identifier string creation, refs AC-1191
* refactor: add addtional unit tests, refs AC-1191
* refactor: update success test to use more generated params, refs AC-1191
* fix: dotnet format...again, refs AC-1191
* refactor: make UTC display a constant for handlebars mail service, refs AC-1191
* refactor: update displayTypeIdentifer to displayTypeAndIdentifier for clarity, refs AC-1191
2023-07-06 10:03:49 -05:00
|
|
|
|
TimeZone = _utcTimeZoneDisplay,
|
2019-02-14 11:49:39 -05:00
|
|
|
|
IpAddress = ip
|
2022-08-29 15:53:48 -04:00
|
|
|
|
};
|
2023-04-14 13:25:56 -04:00
|
|
|
|
await AddMessageContentAsync(message, "Auth.RecoverTwoFactor", model);
|
2019-03-13 16:19:00 -04:00
|
|
|
|
message.Category = "RecoverTwoFactor";
|
2019-02-14 11:49:39 -05:00
|
|
|
|
await _mailDeliveryService.SendEmailAsync(message);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2019-02-22 21:13:34 -05:00
|
|
|
|
public async Task SendOrganizationUserRemovedForPolicySingleOrgEmailAsync(string organizationName, string email)
|
|
|
|
|
|
{
|
|
|
|
|
|
var message = CreateDefaultMessage($"You have been removed from {organizationName}", email);
|
2020-12-16 20:36:47 +01:00
|
|
|
|
var model = new OrganizationUserRemovedForPolicySingleOrgViewModel
|
2022-08-29 16:06:55 -04:00
|
|
|
|
{
|
2020-12-16 20:36:47 +01:00
|
|
|
|
OrganizationName = CoreHelpers.SanitizeForEmail(organizationName, false),
|
2019-02-22 21:13:34 -05:00
|
|
|
|
WebVaultUrl = _globalSettings.BaseServiceUri.VaultWithHash,
|
|
|
|
|
|
SiteName = _globalSettings.SiteName
|
|
|
|
|
|
};
|
|
|
|
|
|
await AddMessageContentAsync(message, "OrganizationUserRemovedForPolicySingleOrg", model);
|
|
|
|
|
|
message.Category = "OrganizationUserRemovedForPolicySingleOrg";
|
|
|
|
|
|
await _mailDeliveryService.SendEmailAsync(message);
|
|
|
|
|
|
}
|
2021-12-16 15:35:09 +01:00
|
|
|
|
|
2020-05-19 18:22:03 -04:00
|
|
|
|
public async Task SendEnqueuedMailMessageAsync(IMailQueueMessage queueMessage)
|
2020-05-18 16:06:34 -04:00
|
|
|
|
{
|
|
|
|
|
|
var message = CreateDefaultMessage(queueMessage.Subject, queueMessage.ToEmails);
|
2021-07-21 12:43:28 -04:00
|
|
|
|
message.BccEmails = queueMessage.BccEmails;
|
|
|
|
|
|
message.Category = queueMessage.Category;
|
2020-05-18 16:06:34 -04:00
|
|
|
|
await AddMessageContentAsync(message, queueMessage.TemplateName, queueMessage.Model);
|
|
|
|
|
|
await _mailDeliveryService.SendEmailAsync(message);
|
|
|
|
|
|
}
|
2019-02-22 21:13:34 -05:00
|
|
|
|
|
2019-01-24 22:37:49 -05:00
|
|
|
|
public async Task SendAdminResetPasswordEmailAsync(string email, string userName, string orgName)
|
2022-08-29 15:53:48 -04:00
|
|
|
|
{
|
2023-06-01 08:57:35 +01:00
|
|
|
|
var message = CreateDefaultMessage("Your admin has initiated account recovery", email);
|
2022-05-10 17:12:09 -04:00
|
|
|
|
var model = new AdminResetPasswordViewModel()
|
2022-08-29 15:53:48 -04:00
|
|
|
|
{
|
2019-01-24 22:37:49 -05:00
|
|
|
|
UserName = GetUserIdentifier(email, userName),
|
|
|
|
|
|
OrgName = CoreHelpers.SanitizeForEmail(orgName, false),
|
2022-08-29 15:53:48 -04:00
|
|
|
|
};
|
2019-01-24 22:37:49 -05:00
|
|
|
|
await AddMessageContentAsync(message, "AdminResetPassword", model);
|
|
|
|
|
|
message.Category = "AdminResetPassword";
|
|
|
|
|
|
await _mailDeliveryService.SendEmailAsync(message);
|
2022-08-29 15:53:48 -04:00
|
|
|
|
}
|
2019-01-24 22:37:49 -05:00
|
|
|
|
|
2019-12-23 15:26:39 -05:00
|
|
|
|
private Task EnqueueMailAsync(IMailQueueMessage queueMessage) =>
|
|
|
|
|
|
_mailEnqueuingService.EnqueueAsync(queueMessage, SendEnqueuedMailMessageAsync);
|
|
|
|
|
|
|
2020-10-27 10:28:41 -04:00
|
|
|
|
private Task EnqueueMailAsync(IEnumerable<IMailQueueMessage> queueMessages) =>
|
2020-10-20 02:48:10 -04:00
|
|
|
|
_mailEnqueuingService.EnqueueManyAsync(queueMessages, SendEnqueuedMailMessageAsync);
|
|
|
|
|
|
|
2021-05-17 09:43:02 -05:00
|
|
|
|
private MailMessage CreateDefaultMessage(string subject, string toEmail)
|
|
|
|
|
|
{
|
|
|
|
|
|
return CreateDefaultMessage(subject, new List<string> { toEmail });
|
|
|
|
|
|
}
|
2021-12-16 15:35:09 +01:00
|
|
|
|
|
2021-05-26 16:54:25 -05:00
|
|
|
|
private MailMessage CreateDefaultMessage(string subject, IEnumerable<string> toEmails)
|
2022-08-29 16:06:55 -04:00
|
|
|
|
{
|
2021-05-26 16:54:25 -05:00
|
|
|
|
return new MailMessage
|
2022-08-29 14:53:16 -04:00
|
|
|
|
{
|
2021-05-26 16:54:25 -05:00
|
|
|
|
ToEmails = toEmails,
|
|
|
|
|
|
Subject = subject,
|
2018-08-03 23:04:47 -04:00
|
|
|
|
MetaData = new Dictionary<string, object>()
|
|
|
|
|
|
};
|
2022-08-29 14:53:16 -04:00
|
|
|
|
}
|
|
|
|
|
|
|
2021-05-26 16:54:25 -05:00
|
|
|
|
private async Task AddMessageContentAsync<T>(MailMessage message, string templateName, T model)
|
2022-08-29 16:06:55 -04:00
|
|
|
|
{
|
2021-05-26 16:54:25 -05:00
|
|
|
|
message.HtmlContent = await RenderAsync($"{templateName}.html", model);
|
2021-11-09 16:37:32 +01:00
|
|
|
|
message.TextContent = await RenderAsync($"{templateName}.text", model);
|
2022-08-29 16:06:55 -04:00
|
|
|
|
}
|
|
|
|
|
|
|
2021-05-26 16:54:25 -05:00
|
|
|
|
private async Task<string> RenderAsync<T>(string templateName, T model)
|
2022-08-29 16:06:55 -04:00
|
|
|
|
{
|
2021-05-26 16:54:25 -05:00
|
|
|
|
await RegisterHelpersAndPartialsAsync();
|
|
|
|
|
|
if (!_templateCache.TryGetValue(templateName, out var template))
|
|
|
|
|
|
{
|
|
|
|
|
|
var source = await ReadSourceAsync(templateName);
|
|
|
|
|
|
if (source != null)
|
|
|
|
|
|
{
|
2022-08-02 12:57:56 -07:00
|
|
|
|
template = Handlebars.Compile(source);
|
2021-05-26 16:54:25 -05:00
|
|
|
|
_templateCache.Add(templateName, template);
|
2022-08-29 16:06:55 -04:00
|
|
|
|
}
|
2021-05-26 16:54:25 -05:00
|
|
|
|
}
|
2018-08-03 23:04:47 -04:00
|
|
|
|
return template != null ? template(model) : null;
|
2022-08-29 16:06:55 -04:00
|
|
|
|
}
|
2021-05-17 09:43:02 -05:00
|
|
|
|
|
2018-08-03 23:04:47 -04:00
|
|
|
|
private async Task<string> ReadSourceAsync(string templateName)
|
2022-08-29 16:06:55 -04:00
|
|
|
|
{
|
2018-08-03 23:04:47 -04:00
|
|
|
|
var assembly = typeof(HandlebarsMailService).GetTypeInfo().Assembly;
|
|
|
|
|
|
var fullTemplateName = $"{Namespace}.{templateName}.hbs";
|
|
|
|
|
|
if (!assembly.GetManifestResourceNames().Any(f => f == fullTemplateName))
|
|
|
|
|
|
{
|
|
|
|
|
|
return null;
|
|
|
|
|
|
}
|
|
|
|
|
|
using (var s = assembly.GetManifestResourceStream(fullTemplateName))
|
|
|
|
|
|
using (var sr = new StreamReader(s))
|
|
|
|
|
|
{
|
|
|
|
|
|
return await sr.ReadToEndAsync();
|
|
|
|
|
|
}
|
2022-08-29 16:06:55 -04:00
|
|
|
|
}
|
2018-08-03 23:04:47 -04:00
|
|
|
|
|
|
|
|
|
|
private async Task RegisterHelpersAndPartialsAsync()
|
2022-08-29 16:06:55 -04:00
|
|
|
|
{
|
2018-08-03 23:04:47 -04:00
|
|
|
|
if (_registeredHelpersAndPartials)
|
|
|
|
|
|
{
|
2021-11-09 16:37:32 +01:00
|
|
|
|
return;
|
2018-08-03 23:04:47 -04:00
|
|
|
|
}
|
|
|
|
|
|
_registeredHelpersAndPartials = true;
|
2022-08-29 16:06:55 -04:00
|
|
|
|
|
2018-08-03 23:04:47 -04:00
|
|
|
|
var basicHtmlLayoutSource = await ReadSourceAsync("Layouts.Basic.html");
|
|
|
|
|
|
Handlebars.RegisterTemplate("BasicHtmlLayout", basicHtmlLayoutSource);
|
|
|
|
|
|
var basicTextLayoutSource = await ReadSourceAsync("Layouts.Basic.text");
|
|
|
|
|
|
Handlebars.RegisterTemplate("BasicTextLayout", basicTextLayoutSource);
|
|
|
|
|
|
var fullHtmlLayoutSource = await ReadSourceAsync("Layouts.Full.html");
|
|
|
|
|
|
Handlebars.RegisterTemplate("FullHtmlLayout", fullHtmlLayoutSource);
|
|
|
|
|
|
var fullTextLayoutSource = await ReadSourceAsync("Layouts.Full.text");
|
|
|
|
|
|
Handlebars.RegisterTemplate("FullTextLayout", fullTextLayoutSource);
|
2023-04-13 18:19:49 +01:00
|
|
|
|
var fullUpdatedHtmlLayoutSource = await ReadSourceAsync("Layouts.FullUpdated.html");
|
|
|
|
|
|
Handlebars.RegisterTemplate("FullUpdatedHtmlLayout", fullUpdatedHtmlLayoutSource);
|
|
|
|
|
|
var fullUpdatedTextLayoutSource = await ReadSourceAsync("Layouts.FullUpdated.text");
|
|
|
|
|
|
Handlebars.RegisterTemplate("FullUpdatedTextLayout", fullUpdatedTextLayoutSource);
|
2023-03-21 14:44:58 +00:00
|
|
|
|
var titleContactUsHtmlLayoutSource = await ReadSourceAsync("Layouts.TitleContactUs.html");
|
|
|
|
|
|
Handlebars.RegisterTemplate("TitleContactUsHtmlLayout", titleContactUsHtmlLayoutSource);
|
|
|
|
|
|
var titleContactUsTextLayoutSource = await ReadSourceAsync("Layouts.TitleContactUs.text");
|
|
|
|
|
|
Handlebars.RegisterTemplate("TitleContactUsTextLayout", titleContactUsTextLayoutSource);
|
2018-08-03 23:04:47 -04:00
|
|
|
|
|
|
|
|
|
|
Handlebars.RegisterHelper("date", (writer, context, parameters) =>
|
|
|
|
|
|
{
|
|
|
|
|
|
if (parameters.Length == 0 || !(parameters[0] is DateTime))
|
|
|
|
|
|
{
|
|
|
|
|
|
writer.WriteSafeString(string.Empty);
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
2020-03-27 14:36:37 -04:00
|
|
|
|
if (parameters.Length > 0 && parameters[1] is string)
|
2018-08-03 23:04:47 -04:00
|
|
|
|
{
|
|
|
|
|
|
writer.WriteSafeString(((DateTime)parameters[0]).ToString(parameters[1].ToString()));
|
2022-08-29 15:53:48 -04:00
|
|
|
|
}
|
2018-08-03 23:04:47 -04:00
|
|
|
|
else
|
2022-08-29 15:53:48 -04:00
|
|
|
|
{
|
2018-08-03 23:04:47 -04:00
|
|
|
|
writer.WriteSafeString(((DateTime)parameters[0]).ToString());
|
|
|
|
|
|
}
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
Handlebars.RegisterHelper("usd", (writer, context, parameters) =>
|
2022-08-29 14:53:16 -04:00
|
|
|
|
{
|
2020-03-27 14:36:37 -04:00
|
|
|
|
if (parameters.Length == 0 || !(parameters[0] is decimal))
|
2018-08-03 23:04:47 -04:00
|
|
|
|
{
|
|
|
|
|
|
writer.WriteSafeString(string.Empty);
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
2020-03-27 14:36:37 -04:00
|
|
|
|
writer.WriteSafeString(((decimal)parameters[0]).ToString("C"));
|
2022-08-29 15:53:48 -04:00
|
|
|
|
});
|
|
|
|
|
|
|
2020-03-27 14:36:37 -04:00
|
|
|
|
Handlebars.RegisterHelper("link", (writer, context, parameters) =>
|
2022-08-29 16:06:55 -04:00
|
|
|
|
{
|
2020-03-27 14:36:37 -04:00
|
|
|
|
if (parameters.Length == 0)
|
2022-08-29 14:53:16 -04:00
|
|
|
|
{
|
2018-08-03 23:04:47 -04:00
|
|
|
|
writer.WriteSafeString(string.Empty);
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
2022-08-29 15:53:48 -04:00
|
|
|
|
|
2020-03-27 14:36:37 -04:00
|
|
|
|
var text = parameters[0].ToString();
|
|
|
|
|
|
var href = text;
|
|
|
|
|
|
var clickTrackingOff = false;
|
|
|
|
|
|
if (parameters.Length == 2)
|
2022-08-29 15:53:48 -04:00
|
|
|
|
{
|
2020-03-27 14:36:37 -04:00
|
|
|
|
if (parameters[1] is string)
|
2022-08-29 15:53:48 -04:00
|
|
|
|
{
|
2020-03-27 14:36:37 -04:00
|
|
|
|
var p1 = parameters[1].ToString();
|
|
|
|
|
|
if (p1 == "true" || p1 == "false")
|
2018-08-03 23:04:47 -04:00
|
|
|
|
{
|
|
|
|
|
|
clickTrackingOff = p1 == "true";
|
2022-08-29 15:53:48 -04:00
|
|
|
|
}
|
2020-03-27 14:36:37 -04:00
|
|
|
|
else
|
2022-08-29 15:53:48 -04:00
|
|
|
|
{
|
2018-08-03 23:04:47 -04:00
|
|
|
|
href = p1;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2020-03-27 14:36:37 -04:00
|
|
|
|
else if (parameters[1] is bool)
|
2022-08-29 14:53:16 -04:00
|
|
|
|
{
|
2018-08-03 23:04:47 -04:00
|
|
|
|
clickTrackingOff = (bool)parameters[1];
|
2022-08-29 16:06:55 -04:00
|
|
|
|
}
|
|
|
|
|
|
}
|
2020-03-27 14:36:37 -04:00
|
|
|
|
else if (parameters.Length > 2)
|
2022-08-29 16:06:55 -04:00
|
|
|
|
{
|
2020-03-27 14:36:37 -04:00
|
|
|
|
if (parameters[1] is string)
|
2022-08-29 15:53:48 -04:00
|
|
|
|
{
|
2018-08-03 23:04:47 -04:00
|
|
|
|
href = parameters[1].ToString();
|
2022-08-29 15:53:48 -04:00
|
|
|
|
}
|
2020-03-27 14:36:37 -04:00
|
|
|
|
if (parameters[2] is string)
|
2022-08-29 15:53:48 -04:00
|
|
|
|
{
|
2020-03-27 14:36:37 -04:00
|
|
|
|
var p2 = parameters[2].ToString();
|
|
|
|
|
|
if (p2 == "true" || p2 == "false")
|
2022-08-29 15:53:48 -04:00
|
|
|
|
{
|
2018-08-03 23:04:47 -04:00
|
|
|
|
clickTrackingOff = p2 == "true";
|
2022-08-29 15:53:48 -04:00
|
|
|
|
}
|
2022-08-29 14:53:16 -04:00
|
|
|
|
}
|
2020-03-27 14:36:37 -04:00
|
|
|
|
else if (parameters[2] is bool)
|
2022-08-29 16:06:55 -04:00
|
|
|
|
{
|
2018-08-03 23:04:47 -04:00
|
|
|
|
clickTrackingOff = (bool)parameters[2];
|
2022-08-29 16:06:55 -04:00
|
|
|
|
}
|
|
|
|
|
|
}
|
2020-12-16 20:36:47 +01:00
|
|
|
|
|
|
|
|
|
|
var clickTrackingText = (clickTrackingOff ? "clicktracking=off" : string.Empty);
|
|
|
|
|
|
writer.WriteSafeString($"<a href=\"{href}\" target=\"_blank\" {clickTrackingText}>{text}</a>");
|
2022-08-29 15:53:48 -04:00
|
|
|
|
});
|
|
|
|
|
|
}
|
2020-12-16 20:36:47 +01:00
|
|
|
|
|
|
|
|
|
|
public async Task SendEmergencyAccessInviteEmailAsync(EmergencyAccess emergencyAccess, string name, string token)
|
2022-08-29 15:53:48 -04:00
|
|
|
|
{
|
2020-12-16 20:36:47 +01:00
|
|
|
|
var message = CreateDefaultMessage($"Emergency Access Contact Invite", emergencyAccess.Email);
|
|
|
|
|
|
var model = new EmergencyAccessInvitedViewModel
|
2022-08-29 15:53:48 -04:00
|
|
|
|
{
|
2020-12-16 20:36:47 +01:00
|
|
|
|
Name = CoreHelpers.SanitizeForEmail(name),
|
|
|
|
|
|
Email = WebUtility.UrlEncode(emergencyAccess.Email),
|
|
|
|
|
|
Id = emergencyAccess.Id.ToString(),
|
|
|
|
|
|
Token = WebUtility.UrlEncode(token),
|
|
|
|
|
|
WebVaultUrl = _globalSettings.BaseServiceUri.VaultWithHash,
|
|
|
|
|
|
SiteName = _globalSettings.SiteName
|
2022-08-29 15:53:48 -04:00
|
|
|
|
};
|
2023-04-14 13:25:56 -04:00
|
|
|
|
await AddMessageContentAsync(message, "Auth.EmergencyAccessInvited", model);
|
2020-12-16 20:36:47 +01:00
|
|
|
|
message.Category = "EmergencyAccessInvited";
|
|
|
|
|
|
await _mailDeliveryService.SendEmailAsync(message);
|
2022-08-29 15:53:48 -04:00
|
|
|
|
}
|
2021-12-16 15:35:09 +01:00
|
|
|
|
|
2020-12-16 20:36:47 +01:00
|
|
|
|
public async Task SendEmergencyAccessAcceptedEmailAsync(string granteeEmail, string email)
|
|
|
|
|
|
{
|
|
|
|
|
|
var message = CreateDefaultMessage($"Accepted Emergency Access", email);
|
|
|
|
|
|
var model = new EmergencyAccessAcceptedViewModel
|
2022-08-29 15:53:48 -04:00
|
|
|
|
{
|
2020-12-16 20:36:47 +01:00
|
|
|
|
GranteeEmail = granteeEmail,
|
|
|
|
|
|
WebVaultUrl = _globalSettings.BaseServiceUri.VaultWithHash,
|
|
|
|
|
|
SiteName = _globalSettings.SiteName
|
|
|
|
|
|
};
|
2023-04-14 13:25:56 -04:00
|
|
|
|
await AddMessageContentAsync(message, "Auth.EmergencyAccessAccepted", model);
|
2020-12-16 20:36:47 +01:00
|
|
|
|
message.Category = "EmergencyAccessAccepted";
|
|
|
|
|
|
await _mailDeliveryService.SendEmailAsync(message);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public async Task SendEmergencyAccessConfirmedEmailAsync(string grantorName, string email)
|
|
|
|
|
|
{
|
|
|
|
|
|
var message = CreateDefaultMessage($"You Have Been Confirmed as Emergency Access Contact", email);
|
2021-07-15 16:37:16 +02:00
|
|
|
|
var model = new EmergencyAccessConfirmedViewModel
|
2022-08-29 16:06:55 -04:00
|
|
|
|
{
|
2020-12-16 20:36:47 +01:00
|
|
|
|
Name = CoreHelpers.SanitizeForEmail(grantorName),
|
|
|
|
|
|
WebVaultUrl = _globalSettings.BaseServiceUri.VaultWithHash,
|
|
|
|
|
|
SiteName = _globalSettings.SiteName
|
2022-08-29 16:06:55 -04:00
|
|
|
|
};
|
2023-04-14 13:25:56 -04:00
|
|
|
|
await AddMessageContentAsync(message, "Auth.EmergencyAccessConfirmed", model);
|
2020-12-16 20:36:47 +01:00
|
|
|
|
message.Category = "EmergencyAccessConfirmed";
|
|
|
|
|
|
await _mailDeliveryService.SendEmailAsync(message);
|
2022-08-29 16:06:55 -04:00
|
|
|
|
}
|
2020-12-16 20:36:47 +01:00
|
|
|
|
|
|
|
|
|
|
public async Task SendEmergencyAccessRecoveryInitiated(EmergencyAccess emergencyAccess, string initiatingName, string email)
|
2022-08-29 16:06:55 -04:00
|
|
|
|
{
|
2020-12-16 20:36:47 +01:00
|
|
|
|
var message = CreateDefaultMessage("Emergency Access Initiated", email);
|
|
|
|
|
|
|
|
|
|
|
|
var remainingTime = DateTime.UtcNow - emergencyAccess.RecoveryInitiatedDate.GetValueOrDefault();
|
2021-12-16 15:35:09 +01:00
|
|
|
|
|
2020-12-16 20:36:47 +01:00
|
|
|
|
var model = new EmergencyAccessRecoveryViewModel
|
2022-08-29 15:53:48 -04:00
|
|
|
|
{
|
2020-12-16 20:36:47 +01:00
|
|
|
|
Name = CoreHelpers.SanitizeForEmail(initiatingName),
|
|
|
|
|
|
Action = emergencyAccess.Type.ToString(),
|
2021-07-23 10:22:59 +02:00
|
|
|
|
DaysLeft = emergencyAccess.WaitTimeDays - Convert.ToInt32((remainingTime).TotalDays),
|
2022-08-29 15:53:48 -04:00
|
|
|
|
};
|
2023-04-14 13:25:56 -04:00
|
|
|
|
await AddMessageContentAsync(message, "Auth.EmergencyAccessRecovery", model);
|
2020-12-16 20:36:47 +01:00
|
|
|
|
message.Category = "EmergencyAccessRecovery";
|
|
|
|
|
|
await _mailDeliveryService.SendEmailAsync(message);
|
2022-08-29 15:53:48 -04:00
|
|
|
|
}
|
2020-12-16 20:36:47 +01:00
|
|
|
|
|
|
|
|
|
|
public async Task SendEmergencyAccessRecoveryApproved(EmergencyAccess emergencyAccess, string approvingName, string email)
|
|
|
|
|
|
{
|
|
|
|
|
|
var message = CreateDefaultMessage("Emergency Access Approved", email);
|
|
|
|
|
|
var model = new EmergencyAccessApprovedViewModel
|
2022-08-29 15:53:48 -04:00
|
|
|
|
{
|
2020-12-16 20:36:47 +01:00
|
|
|
|
Name = CoreHelpers.SanitizeForEmail(approvingName),
|
2022-08-29 14:53:16 -04:00
|
|
|
|
};
|
2023-04-14 13:25:56 -04:00
|
|
|
|
await AddMessageContentAsync(message, "Auth.EmergencyAccessApproved", model);
|
2020-12-16 20:36:47 +01:00
|
|
|
|
message.Category = "EmergencyAccessApproved";
|
|
|
|
|
|
await _mailDeliveryService.SendEmailAsync(message);
|
|
|
|
|
|
}
|
2021-12-16 15:35:09 +01:00
|
|
|
|
|
2021-06-03 18:58:29 +02:00
|
|
|
|
public async Task SendEmergencyAccessRecoveryRejected(EmergencyAccess emergencyAccess, string rejectingName, string email)
|
|
|
|
|
|
{
|
|
|
|
|
|
var message = CreateDefaultMessage("Emergency Access Rejected", email);
|
|
|
|
|
|
var model = new EmergencyAccessRejectedViewModel
|
2022-08-29 16:06:55 -04:00
|
|
|
|
{
|
2021-06-03 18:58:29 +02:00
|
|
|
|
Name = CoreHelpers.SanitizeForEmail(rejectingName),
|
2022-08-29 16:06:55 -04:00
|
|
|
|
};
|
2023-04-14 13:25:56 -04:00
|
|
|
|
await AddMessageContentAsync(message, "Auth.EmergencyAccessRejected", model);
|
2021-07-15 16:37:16 +02:00
|
|
|
|
message.Category = "EmergencyAccessRejected";
|
2021-06-03 18:58:29 +02:00
|
|
|
|
await _mailDeliveryService.SendEmailAsync(message);
|
2022-08-29 16:06:55 -04:00
|
|
|
|
}
|
2021-06-03 18:58:29 +02:00
|
|
|
|
|
|
|
|
|
|
public async Task SendEmergencyAccessRecoveryReminder(EmergencyAccess emergencyAccess, string initiatingName, string email)
|
2022-08-29 16:06:55 -04:00
|
|
|
|
{
|
2021-06-03 18:58:29 +02:00
|
|
|
|
var message = CreateDefaultMessage("Pending Emergency Access Request", email);
|
|
|
|
|
|
|
2021-07-23 10:22:59 +02:00
|
|
|
|
var remainingTime = DateTime.UtcNow - emergencyAccess.RecoveryInitiatedDate.GetValueOrDefault();
|
2021-07-15 16:37:16 +02:00
|
|
|
|
|
|
|
|
|
|
var model = new EmergencyAccessRecoveryViewModel
|
|
|
|
|
|
{
|
|
|
|
|
|
Name = CoreHelpers.SanitizeForEmail(initiatingName),
|
|
|
|
|
|
Action = emergencyAccess.Type.ToString(),
|
|
|
|
|
|
DaysLeft = emergencyAccess.WaitTimeDays - Convert.ToInt32((remainingTime).TotalDays),
|
2022-08-29 16:06:55 -04:00
|
|
|
|
};
|
2023-04-14 13:25:56 -04:00
|
|
|
|
await AddMessageContentAsync(message, "Auth.EmergencyAccessRecoveryReminder", model);
|
2021-07-15 16:37:16 +02:00
|
|
|
|
message.Category = "EmergencyAccessRecoveryReminder";
|
|
|
|
|
|
await _mailDeliveryService.SendEmailAsync(message);
|
|
|
|
|
|
}
|
2021-12-16 15:35:09 +01:00
|
|
|
|
|
2021-07-22 09:20:14 -05:00
|
|
|
|
public async Task SendEmergencyAccessRecoveryTimedOut(EmergencyAccess emergencyAccess, string initiatingName, string email)
|
|
|
|
|
|
{
|
|
|
|
|
|
var message = CreateDefaultMessage("Emergency Access Granted", email);
|
|
|
|
|
|
var model = new EmergencyAccessRecoveryTimedOutViewModel
|
|
|
|
|
|
{
|
2022-06-23 10:44:41 -05:00
|
|
|
|
Name = CoreHelpers.SanitizeForEmail(initiatingName),
|
2021-06-03 18:58:29 +02:00
|
|
|
|
Action = emergencyAccess.Type.ToString(),
|
2021-07-22 09:20:14 -05:00
|
|
|
|
};
|
2023-04-14 13:25:56 -04:00
|
|
|
|
await AddMessageContentAsync(message, "Auth.EmergencyAccessRecoveryTimedOut", model);
|
2021-07-22 09:20:14 -05:00
|
|
|
|
message.Category = "EmergencyAccessRecoveryTimedOut";
|
|
|
|
|
|
await _mailDeliveryService.SendEmailAsync(message);
|
|
|
|
|
|
}
|
2021-11-09 16:37:32 +01:00
|
|
|
|
|
2022-05-10 17:12:09 -04:00
|
|
|
|
public async Task SendProviderSetupInviteEmailAsync(Provider provider, string token, string email)
|
2022-08-29 14:53:16 -04:00
|
|
|
|
{
|
2022-05-10 17:12:09 -04:00
|
|
|
|
var message = CreateDefaultMessage($"Create a Provider", email);
|
|
|
|
|
|
var model = new ProviderSetupInviteViewModel
|
|
|
|
|
|
{
|
|
|
|
|
|
WebVaultUrl = _globalSettings.BaseServiceUri.VaultWithHash,
|
2021-06-03 18:58:29 +02:00
|
|
|
|
SiteName = _globalSettings.SiteName,
|
2022-05-10 17:12:09 -04:00
|
|
|
|
ProviderId = provider.Id.ToString(),
|
2021-07-23 10:22:59 +02:00
|
|
|
|
Email = WebUtility.UrlEncode(email),
|
|
|
|
|
|
Token = WebUtility.UrlEncode(token),
|
2022-05-10 17:12:09 -04:00
|
|
|
|
};
|
|
|
|
|
|
await AddMessageContentAsync(message, "Provider.ProviderSetupInvite", model);
|
|
|
|
|
|
message.Category = "ProviderSetupInvite";
|
|
|
|
|
|
await _mailDeliveryService.SendEmailAsync(message);
|
2022-08-29 14:53:16 -04:00
|
|
|
|
}
|
Families for Enterprise (#1714)
* Create common test infrastructure project
* Add helpers to further type PlanTypes
* Enable testing of ASP.net MVC controllers
Controller properties have all kinds of validations in the background.
In general, we don't user properties on our Controllers, so the easiest
way to allow for Autofixture-based testing of our Controllers is to just
omit setting all properties on them.
* Workaround for broken MemberAutoDataAttribute
https://github.com/AutoFixture/AutoFixture/pull/1164 shows that only
the first test case is pulled for this attribute.
This is a workaround that populates the provided parameters, left to
right, using AutoFixture to populate any remaining.
* WIP: Organization sponsorship flow
* Add Attribute to use the Bit Autodata dependency chain
BitAutoDataAttribute is used to mark a Theory as autopopulating
parameters.
Extract common attribute methods to to a helper class. Cannot
inherit a common base, since both require inheriting from different
Xunit base classes to work.
* WIP: scaffolding for families for enterprise sponsorship flow
* Fix broken tests
* Create sponsorship offer (#1688)
* Initial db work (#1687)
* Add organization sponsorship databases to all providers
* Generalize create and update for database, specialize in code
* Add PlanSponsorshipType to db model
* Write valid json for test entries
* Initial scaffolding of emails (#1686)
* Initial scaffolding of emails
* Work on adding models for FamilyForEnterprise emails
* Switch verbage
* Put preliminary copy in emails
* Skip test
* Families for enterprise/stripe integrations (#1699)
* Add PlanSponsorshipType to static store
* Add sponsorship type to token and creates sponsorship
* PascalCase properties
* Require sponsorship for remove
* Create subscription sponsorship helper class
* Handle Sponsored subscription changes
* Add sponsorship id to subscription metadata
* Make sponsoring references nullable
This state indicates that a sponsorship has lapsed, but was not able to
be reverted for billing reasons
* WIP: Validate and remove subscriptions
* Update sponsorships on organization and org user delete
* Add friendly name to organization sponsorship
* Add sponsorship available boolean to orgDetails
* Add sponsorship service to DI
* Use userId to find org users
* Send f4e offer email
* Simplify names of f4e mail messages
* Fix Stripe org default tax rates
* Universal sponsorship redeem api
* Populate user in current context
* Add product type to organization details
* Use upgrade path to change sponsorship
Sponsorships need to be annual to match the GB add-on charge rate
* Use organization and auth to find organization sponsorship
* Add resend sponsorship offer api endpoint
* Fix double email send
* Fix sponsorship upgrade options
* Add is sponsored item to subscription response
* Add sponsorship validation to upcoming invoice webhook
* Add sponsorship validation to upcoming invoice webhook
* Fix organization delete sponsorship hooks
* Test org sponsorship service
* Fix sproc
* Create common test infrastructure project
* Add helpers to further type PlanTypes
* Enable testing of ASP.net MVC controllers
Controller properties have all kinds of validations in the background.
In general, we don't user properties on our Controllers, so the easiest
way to allow for Autofixture-based testing of our Controllers is to just
omit setting all properties on them.
* Workaround for broken MemberAutoDataAttribute
https://github.com/AutoFixture/AutoFixture/pull/1164 shows that only
the first test case is pulled for this attribute.
This is a workaround that populates the provided parameters, left to
right, using AutoFixture to populate any remaining.
* WIP: Organization sponsorship flow
* Add Attribute to use the Bit Autodata dependency chain
BitAutoDataAttribute is used to mark a Theory as autopopulating
parameters.
Extract common attribute methods to to a helper class. Cannot
inherit a common base, since both require inheriting from different
Xunit base classes to work.
* WIP: scaffolding for families for enterprise sponsorship flow
* Fix broken tests
* Create sponsorship offer (#1688)
* Initial db work (#1687)
* Add organization sponsorship databases to all providers
* Generalize create and update for database, specialize in code
* Add PlanSponsorshipType to db model
* Write valid json for test entries
* Initial scaffolding of emails (#1686)
* Initial scaffolding of emails
* Work on adding models for FamilyForEnterprise emails
* Switch verbage
* Put preliminary copy in emails
* Skip test
* Families for enterprise/stripe integrations (#1699)
* Add PlanSponsorshipType to static store
* Add sponsorship type to token and creates sponsorship
* PascalCase properties
* Require sponsorship for remove
* Create subscription sponsorship helper class
* Handle Sponsored subscription changes
* Add sponsorship id to subscription metadata
* Make sponsoring references nullable
This state indicates that a sponsorship has lapsed, but was not able to
be reverted for billing reasons
* WIP: Validate and remove subscriptions
* Update sponsorships on organization and org user delete
* Add friendly name to organization sponsorship
* Add sponsorship available boolean to orgDetails
* Add sponsorship service to DI
* Use userId to find org users
* Send f4e offer email
* Simplify names of f4e mail messages
* Fix Stripe org default tax rates
* Universal sponsorship redeem api
* Populate user in current context
* Add product type to organization details
* Use upgrade path to change sponsorship
Sponsorships need to be annual to match the GB add-on charge rate
* Use organization and auth to find organization sponsorship
* Add resend sponsorship offer api endpoint
* Fix double email send
* Fix sponsorship upgrade options
* Add is sponsored item to subscription response
* Add sponsorship validation to upcoming invoice webhook
* Add sponsorship validation to upcoming invoice webhook
* Fix organization delete sponsorship hooks
* Test org sponsorship service
* Fix sproc
* Fix build error
* Update emails
* Fix tests
* Skip local test
* Add newline
* Fix stripe subscription update
* Finish emails
* Skip test
* Fix unit tests
* Remove unused variable
* Fix unit tests
* Switch to handlebars ifs
* Remove ending email
* Remove reconfirmation template
* Switch naming convention
* Switch naming convention
* Fix migration
* Update copy and links
* Switch to using Guid in the method
* Remove unneeded css styles
* Add sql files to Sql.sqlproj
* Removed old comments
* Made name more verbose
* Fix SQL error
* Move unit tests to service
* Fix sp
* Revert "Move unit tests to service"
This reverts commit 1185bf3ec8ca36ccd75717ed2463adf8885159a6.
* Do repository validation in service layer
* Fix tests
* Fix merge conflicts and remove TODO
* Remove unneeded models
* Fix spacing and formatting
* Switch Org -> Organization
* Remove single use variables
* Switch method name
* Fix Controller
* Switch to obfuscating email
* Fix unit tests
Co-authored-by: Justin Baur <admin@justinbaur.com>
2021-11-19 16:25:06 -06:00
|
|
|
|
|
2022-05-10 17:12:09 -04:00
|
|
|
|
public async Task SendProviderInviteEmailAsync(string providerName, ProviderUser providerUser, string token, string email)
|
|
|
|
|
|
{
|
|
|
|
|
|
var message = CreateDefaultMessage($"Join {providerName}", email);
|
|
|
|
|
|
var model = new ProviderUserInvitedViewModel
|
2022-08-29 15:53:48 -04:00
|
|
|
|
{
|
2022-05-10 17:12:09 -04:00
|
|
|
|
ProviderName = CoreHelpers.SanitizeForEmail(providerName),
|
|
|
|
|
|
Email = WebUtility.UrlEncode(providerUser.Email),
|
2021-06-03 18:58:29 +02:00
|
|
|
|
ProviderId = providerUser.ProviderId.ToString(),
|
2022-05-10 17:12:09 -04:00
|
|
|
|
ProviderUserId = providerUser.Id.ToString(),
|
2021-06-03 18:58:29 +02:00
|
|
|
|
ProviderNameUrlEncoded = WebUtility.UrlEncode(providerName),
|
2021-07-23 10:22:59 +02:00
|
|
|
|
Token = WebUtility.UrlEncode(token),
|
2022-05-10 17:12:09 -04:00
|
|
|
|
WebVaultUrl = _globalSettings.BaseServiceUri.VaultWithHash,
|
2021-07-15 16:37:16 +02:00
|
|
|
|
SiteName = _globalSettings.SiteName,
|
2022-05-10 17:12:09 -04:00
|
|
|
|
};
|
|
|
|
|
|
await AddMessageContentAsync(message, "Provider.ProviderUserInvited", model);
|
|
|
|
|
|
message.Category = "ProviderSetupInvite";
|
|
|
|
|
|
await _mailDeliveryService.SendEmailAsync(message);
|
2022-08-29 15:53:48 -04:00
|
|
|
|
}
|
Families for Enterprise (#1714)
* Create common test infrastructure project
* Add helpers to further type PlanTypes
* Enable testing of ASP.net MVC controllers
Controller properties have all kinds of validations in the background.
In general, we don't user properties on our Controllers, so the easiest
way to allow for Autofixture-based testing of our Controllers is to just
omit setting all properties on them.
* Workaround for broken MemberAutoDataAttribute
https://github.com/AutoFixture/AutoFixture/pull/1164 shows that only
the first test case is pulled for this attribute.
This is a workaround that populates the provided parameters, left to
right, using AutoFixture to populate any remaining.
* WIP: Organization sponsorship flow
* Add Attribute to use the Bit Autodata dependency chain
BitAutoDataAttribute is used to mark a Theory as autopopulating
parameters.
Extract common attribute methods to to a helper class. Cannot
inherit a common base, since both require inheriting from different
Xunit base classes to work.
* WIP: scaffolding for families for enterprise sponsorship flow
* Fix broken tests
* Create sponsorship offer (#1688)
* Initial db work (#1687)
* Add organization sponsorship databases to all providers
* Generalize create and update for database, specialize in code
* Add PlanSponsorshipType to db model
* Write valid json for test entries
* Initial scaffolding of emails (#1686)
* Initial scaffolding of emails
* Work on adding models for FamilyForEnterprise emails
* Switch verbage
* Put preliminary copy in emails
* Skip test
* Families for enterprise/stripe integrations (#1699)
* Add PlanSponsorshipType to static store
* Add sponsorship type to token and creates sponsorship
* PascalCase properties
* Require sponsorship for remove
* Create subscription sponsorship helper class
* Handle Sponsored subscription changes
* Add sponsorship id to subscription metadata
* Make sponsoring references nullable
This state indicates that a sponsorship has lapsed, but was not able to
be reverted for billing reasons
* WIP: Validate and remove subscriptions
* Update sponsorships on organization and org user delete
* Add friendly name to organization sponsorship
* Add sponsorship available boolean to orgDetails
* Add sponsorship service to DI
* Use userId to find org users
* Send f4e offer email
* Simplify names of f4e mail messages
* Fix Stripe org default tax rates
* Universal sponsorship redeem api
* Populate user in current context
* Add product type to organization details
* Use upgrade path to change sponsorship
Sponsorships need to be annual to match the GB add-on charge rate
* Use organization and auth to find organization sponsorship
* Add resend sponsorship offer api endpoint
* Fix double email send
* Fix sponsorship upgrade options
* Add is sponsored item to subscription response
* Add sponsorship validation to upcoming invoice webhook
* Add sponsorship validation to upcoming invoice webhook
* Fix organization delete sponsorship hooks
* Test org sponsorship service
* Fix sproc
* Create common test infrastructure project
* Add helpers to further type PlanTypes
* Enable testing of ASP.net MVC controllers
Controller properties have all kinds of validations in the background.
In general, we don't user properties on our Controllers, so the easiest
way to allow for Autofixture-based testing of our Controllers is to just
omit setting all properties on them.
* Workaround for broken MemberAutoDataAttribute
https://github.com/AutoFixture/AutoFixture/pull/1164 shows that only
the first test case is pulled for this attribute.
This is a workaround that populates the provided parameters, left to
right, using AutoFixture to populate any remaining.
* WIP: Organization sponsorship flow
* Add Attribute to use the Bit Autodata dependency chain
BitAutoDataAttribute is used to mark a Theory as autopopulating
parameters.
Extract common attribute methods to to a helper class. Cannot
inherit a common base, since both require inheriting from different
Xunit base classes to work.
* WIP: scaffolding for families for enterprise sponsorship flow
* Fix broken tests
* Create sponsorship offer (#1688)
* Initial db work (#1687)
* Add organization sponsorship databases to all providers
* Generalize create and update for database, specialize in code
* Add PlanSponsorshipType to db model
* Write valid json for test entries
* Initial scaffolding of emails (#1686)
* Initial scaffolding of emails
* Work on adding models for FamilyForEnterprise emails
* Switch verbage
* Put preliminary copy in emails
* Skip test
* Families for enterprise/stripe integrations (#1699)
* Add PlanSponsorshipType to static store
* Add sponsorship type to token and creates sponsorship
* PascalCase properties
* Require sponsorship for remove
* Create subscription sponsorship helper class
* Handle Sponsored subscription changes
* Add sponsorship id to subscription metadata
* Make sponsoring references nullable
This state indicates that a sponsorship has lapsed, but was not able to
be reverted for billing reasons
* WIP: Validate and remove subscriptions
* Update sponsorships on organization and org user delete
* Add friendly name to organization sponsorship
* Add sponsorship available boolean to orgDetails
* Add sponsorship service to DI
* Use userId to find org users
* Send f4e offer email
* Simplify names of f4e mail messages
* Fix Stripe org default tax rates
* Universal sponsorship redeem api
* Populate user in current context
* Add product type to organization details
* Use upgrade path to change sponsorship
Sponsorships need to be annual to match the GB add-on charge rate
* Use organization and auth to find organization sponsorship
* Add resend sponsorship offer api endpoint
* Fix double email send
* Fix sponsorship upgrade options
* Add is sponsored item to subscription response
* Add sponsorship validation to upcoming invoice webhook
* Add sponsorship validation to upcoming invoice webhook
* Fix organization delete sponsorship hooks
* Test org sponsorship service
* Fix sproc
* Fix build error
* Update emails
* Fix tests
* Skip local test
* Add newline
* Fix stripe subscription update
* Finish emails
* Skip test
* Fix unit tests
* Remove unused variable
* Fix unit tests
* Switch to handlebars ifs
* Remove ending email
* Remove reconfirmation template
* Switch naming convention
* Switch naming convention
* Fix migration
* Update copy and links
* Switch to using Guid in the method
* Remove unneeded css styles
* Add sql files to Sql.sqlproj
* Removed old comments
* Made name more verbose
* Fix SQL error
* Move unit tests to service
* Fix sp
* Revert "Move unit tests to service"
This reverts commit 1185bf3ec8ca36ccd75717ed2463adf8885159a6.
* Do repository validation in service layer
* Fix tests
* Fix merge conflicts and remove TODO
* Remove unneeded models
* Fix spacing and formatting
* Switch Org -> Organization
* Remove single use variables
* Switch method name
* Fix Controller
* Switch to obfuscating email
* Fix unit tests
Co-authored-by: Justin Baur <admin@justinbaur.com>
2021-11-19 16:25:06 -06:00
|
|
|
|
|
|
|
|
|
|
public async Task SendProviderConfirmedEmailAsync(string providerName, string email)
|
|
|
|
|
|
{
|
|
|
|
|
|
var message = CreateDefaultMessage($"You Have Been Confirmed To {providerName}", email);
|
|
|
|
|
|
var model = new ProviderUserConfirmedViewModel
|
2022-08-29 14:53:16 -04:00
|
|
|
|
{
|
Families for Enterprise (#1714)
* Create common test infrastructure project
* Add helpers to further type PlanTypes
* Enable testing of ASP.net MVC controllers
Controller properties have all kinds of validations in the background.
In general, we don't user properties on our Controllers, so the easiest
way to allow for Autofixture-based testing of our Controllers is to just
omit setting all properties on them.
* Workaround for broken MemberAutoDataAttribute
https://github.com/AutoFixture/AutoFixture/pull/1164 shows that only
the first test case is pulled for this attribute.
This is a workaround that populates the provided parameters, left to
right, using AutoFixture to populate any remaining.
* WIP: Organization sponsorship flow
* Add Attribute to use the Bit Autodata dependency chain
BitAutoDataAttribute is used to mark a Theory as autopopulating
parameters.
Extract common attribute methods to to a helper class. Cannot
inherit a common base, since both require inheriting from different
Xunit base classes to work.
* WIP: scaffolding for families for enterprise sponsorship flow
* Fix broken tests
* Create sponsorship offer (#1688)
* Initial db work (#1687)
* Add organization sponsorship databases to all providers
* Generalize create and update for database, specialize in code
* Add PlanSponsorshipType to db model
* Write valid json for test entries
* Initial scaffolding of emails (#1686)
* Initial scaffolding of emails
* Work on adding models for FamilyForEnterprise emails
* Switch verbage
* Put preliminary copy in emails
* Skip test
* Families for enterprise/stripe integrations (#1699)
* Add PlanSponsorshipType to static store
* Add sponsorship type to token and creates sponsorship
* PascalCase properties
* Require sponsorship for remove
* Create subscription sponsorship helper class
* Handle Sponsored subscription changes
* Add sponsorship id to subscription metadata
* Make sponsoring references nullable
This state indicates that a sponsorship has lapsed, but was not able to
be reverted for billing reasons
* WIP: Validate and remove subscriptions
* Update sponsorships on organization and org user delete
* Add friendly name to organization sponsorship
* Add sponsorship available boolean to orgDetails
* Add sponsorship service to DI
* Use userId to find org users
* Send f4e offer email
* Simplify names of f4e mail messages
* Fix Stripe org default tax rates
* Universal sponsorship redeem api
* Populate user in current context
* Add product type to organization details
* Use upgrade path to change sponsorship
Sponsorships need to be annual to match the GB add-on charge rate
* Use organization and auth to find organization sponsorship
* Add resend sponsorship offer api endpoint
* Fix double email send
* Fix sponsorship upgrade options
* Add is sponsored item to subscription response
* Add sponsorship validation to upcoming invoice webhook
* Add sponsorship validation to upcoming invoice webhook
* Fix organization delete sponsorship hooks
* Test org sponsorship service
* Fix sproc
* Create common test infrastructure project
* Add helpers to further type PlanTypes
* Enable testing of ASP.net MVC controllers
Controller properties have all kinds of validations in the background.
In general, we don't user properties on our Controllers, so the easiest
way to allow for Autofixture-based testing of our Controllers is to just
omit setting all properties on them.
* Workaround for broken MemberAutoDataAttribute
https://github.com/AutoFixture/AutoFixture/pull/1164 shows that only
the first test case is pulled for this attribute.
This is a workaround that populates the provided parameters, left to
right, using AutoFixture to populate any remaining.
* WIP: Organization sponsorship flow
* Add Attribute to use the Bit Autodata dependency chain
BitAutoDataAttribute is used to mark a Theory as autopopulating
parameters.
Extract common attribute methods to to a helper class. Cannot
inherit a common base, since both require inheriting from different
Xunit base classes to work.
* WIP: scaffolding for families for enterprise sponsorship flow
* Fix broken tests
* Create sponsorship offer (#1688)
* Initial db work (#1687)
* Add organization sponsorship databases to all providers
* Generalize create and update for database, specialize in code
* Add PlanSponsorshipType to db model
* Write valid json for test entries
* Initial scaffolding of emails (#1686)
* Initial scaffolding of emails
* Work on adding models for FamilyForEnterprise emails
* Switch verbage
* Put preliminary copy in emails
* Skip test
* Families for enterprise/stripe integrations (#1699)
* Add PlanSponsorshipType to static store
* Add sponsorship type to token and creates sponsorship
* PascalCase properties
* Require sponsorship for remove
* Create subscription sponsorship helper class
* Handle Sponsored subscription changes
* Add sponsorship id to subscription metadata
* Make sponsoring references nullable
This state indicates that a sponsorship has lapsed, but was not able to
be reverted for billing reasons
* WIP: Validate and remove subscriptions
* Update sponsorships on organization and org user delete
* Add friendly name to organization sponsorship
* Add sponsorship available boolean to orgDetails
* Add sponsorship service to DI
* Use userId to find org users
* Send f4e offer email
* Simplify names of f4e mail messages
* Fix Stripe org default tax rates
* Universal sponsorship redeem api
* Populate user in current context
* Add product type to organization details
* Use upgrade path to change sponsorship
Sponsorships need to be annual to match the GB add-on charge rate
* Use organization and auth to find organization sponsorship
* Add resend sponsorship offer api endpoint
* Fix double email send
* Fix sponsorship upgrade options
* Add is sponsored item to subscription response
* Add sponsorship validation to upcoming invoice webhook
* Add sponsorship validation to upcoming invoice webhook
* Fix organization delete sponsorship hooks
* Test org sponsorship service
* Fix sproc
* Fix build error
* Update emails
* Fix tests
* Skip local test
* Add newline
* Fix stripe subscription update
* Finish emails
* Skip test
* Fix unit tests
* Remove unused variable
* Fix unit tests
* Switch to handlebars ifs
* Remove ending email
* Remove reconfirmation template
* Switch naming convention
* Switch naming convention
* Fix migration
* Update copy and links
* Switch to using Guid in the method
* Remove unneeded css styles
* Add sql files to Sql.sqlproj
* Removed old comments
* Made name more verbose
* Fix SQL error
* Move unit tests to service
* Fix sp
* Revert "Move unit tests to service"
This reverts commit 1185bf3ec8ca36ccd75717ed2463adf8885159a6.
* Do repository validation in service layer
* Fix tests
* Fix merge conflicts and remove TODO
* Remove unneeded models
* Fix spacing and formatting
* Switch Org -> Organization
* Remove single use variables
* Switch method name
* Fix Controller
* Switch to obfuscating email
* Fix unit tests
Co-authored-by: Justin Baur <admin@justinbaur.com>
2021-11-19 16:25:06 -06:00
|
|
|
|
ProviderName = CoreHelpers.SanitizeForEmail(providerName),
|
|
|
|
|
|
WebVaultUrl = _globalSettings.BaseServiceUri.VaultWithHash,
|
2022-05-10 17:12:09 -04:00
|
|
|
|
SiteName = _globalSettings.SiteName
|
Families for Enterprise (#1714)
* Create common test infrastructure project
* Add helpers to further type PlanTypes
* Enable testing of ASP.net MVC controllers
Controller properties have all kinds of validations in the background.
In general, we don't user properties on our Controllers, so the easiest
way to allow for Autofixture-based testing of our Controllers is to just
omit setting all properties on them.
* Workaround for broken MemberAutoDataAttribute
https://github.com/AutoFixture/AutoFixture/pull/1164 shows that only
the first test case is pulled for this attribute.
This is a workaround that populates the provided parameters, left to
right, using AutoFixture to populate any remaining.
* WIP: Organization sponsorship flow
* Add Attribute to use the Bit Autodata dependency chain
BitAutoDataAttribute is used to mark a Theory as autopopulating
parameters.
Extract common attribute methods to to a helper class. Cannot
inherit a common base, since both require inheriting from different
Xunit base classes to work.
* WIP: scaffolding for families for enterprise sponsorship flow
* Fix broken tests
* Create sponsorship offer (#1688)
* Initial db work (#1687)
* Add organization sponsorship databases to all providers
* Generalize create and update for database, specialize in code
* Add PlanSponsorshipType to db model
* Write valid json for test entries
* Initial scaffolding of emails (#1686)
* Initial scaffolding of emails
* Work on adding models for FamilyForEnterprise emails
* Switch verbage
* Put preliminary copy in emails
* Skip test
* Families for enterprise/stripe integrations (#1699)
* Add PlanSponsorshipType to static store
* Add sponsorship type to token and creates sponsorship
* PascalCase properties
* Require sponsorship for remove
* Create subscription sponsorship helper class
* Handle Sponsored subscription changes
* Add sponsorship id to subscription metadata
* Make sponsoring references nullable
This state indicates that a sponsorship has lapsed, but was not able to
be reverted for billing reasons
* WIP: Validate and remove subscriptions
* Update sponsorships on organization and org user delete
* Add friendly name to organization sponsorship
* Add sponsorship available boolean to orgDetails
* Add sponsorship service to DI
* Use userId to find org users
* Send f4e offer email
* Simplify names of f4e mail messages
* Fix Stripe org default tax rates
* Universal sponsorship redeem api
* Populate user in current context
* Add product type to organization details
* Use upgrade path to change sponsorship
Sponsorships need to be annual to match the GB add-on charge rate
* Use organization and auth to find organization sponsorship
* Add resend sponsorship offer api endpoint
* Fix double email send
* Fix sponsorship upgrade options
* Add is sponsored item to subscription response
* Add sponsorship validation to upcoming invoice webhook
* Add sponsorship validation to upcoming invoice webhook
* Fix organization delete sponsorship hooks
* Test org sponsorship service
* Fix sproc
* Create common test infrastructure project
* Add helpers to further type PlanTypes
* Enable testing of ASP.net MVC controllers
Controller properties have all kinds of validations in the background.
In general, we don't user properties on our Controllers, so the easiest
way to allow for Autofixture-based testing of our Controllers is to just
omit setting all properties on them.
* Workaround for broken MemberAutoDataAttribute
https://github.com/AutoFixture/AutoFixture/pull/1164 shows that only
the first test case is pulled for this attribute.
This is a workaround that populates the provided parameters, left to
right, using AutoFixture to populate any remaining.
* WIP: Organization sponsorship flow
* Add Attribute to use the Bit Autodata dependency chain
BitAutoDataAttribute is used to mark a Theory as autopopulating
parameters.
Extract common attribute methods to to a helper class. Cannot
inherit a common base, since both require inheriting from different
Xunit base classes to work.
* WIP: scaffolding for families for enterprise sponsorship flow
* Fix broken tests
* Create sponsorship offer (#1688)
* Initial db work (#1687)
* Add organization sponsorship databases to all providers
* Generalize create and update for database, specialize in code
* Add PlanSponsorshipType to db model
* Write valid json for test entries
* Initial scaffolding of emails (#1686)
* Initial scaffolding of emails
* Work on adding models for FamilyForEnterprise emails
* Switch verbage
* Put preliminary copy in emails
* Skip test
* Families for enterprise/stripe integrations (#1699)
* Add PlanSponsorshipType to static store
* Add sponsorship type to token and creates sponsorship
* PascalCase properties
* Require sponsorship for remove
* Create subscription sponsorship helper class
* Handle Sponsored subscription changes
* Add sponsorship id to subscription metadata
* Make sponsoring references nullable
This state indicates that a sponsorship has lapsed, but was not able to
be reverted for billing reasons
* WIP: Validate and remove subscriptions
* Update sponsorships on organization and org user delete
* Add friendly name to organization sponsorship
* Add sponsorship available boolean to orgDetails
* Add sponsorship service to DI
* Use userId to find org users
* Send f4e offer email
* Simplify names of f4e mail messages
* Fix Stripe org default tax rates
* Universal sponsorship redeem api
* Populate user in current context
* Add product type to organization details
* Use upgrade path to change sponsorship
Sponsorships need to be annual to match the GB add-on charge rate
* Use organization and auth to find organization sponsorship
* Add resend sponsorship offer api endpoint
* Fix double email send
* Fix sponsorship upgrade options
* Add is sponsored item to subscription response
* Add sponsorship validation to upcoming invoice webhook
* Add sponsorship validation to upcoming invoice webhook
* Fix organization delete sponsorship hooks
* Test org sponsorship service
* Fix sproc
* Fix build error
* Update emails
* Fix tests
* Skip local test
* Add newline
* Fix stripe subscription update
* Finish emails
* Skip test
* Fix unit tests
* Remove unused variable
* Fix unit tests
* Switch to handlebars ifs
* Remove ending email
* Remove reconfirmation template
* Switch naming convention
* Switch naming convention
* Fix migration
* Update copy and links
* Switch to using Guid in the method
* Remove unneeded css styles
* Add sql files to Sql.sqlproj
* Removed old comments
* Made name more verbose
* Fix SQL error
* Move unit tests to service
* Fix sp
* Revert "Move unit tests to service"
This reverts commit 1185bf3ec8ca36ccd75717ed2463adf8885159a6.
* Do repository validation in service layer
* Fix tests
* Fix merge conflicts and remove TODO
* Remove unneeded models
* Fix spacing and formatting
* Switch Org -> Organization
* Remove single use variables
* Switch method name
* Fix Controller
* Switch to obfuscating email
* Fix unit tests
Co-authored-by: Justin Baur <admin@justinbaur.com>
2021-11-19 16:25:06 -06:00
|
|
|
|
};
|
|
|
|
|
|
await AddMessageContentAsync(message, "Provider.ProviderUserConfirmed", model);
|
|
|
|
|
|
message.Category = "ProviderUserConfirmed";
|
|
|
|
|
|
await _mailDeliveryService.SendEmailAsync(message);
|
2022-08-29 15:53:48 -04:00
|
|
|
|
}
|
Families for Enterprise (#1714)
* Create common test infrastructure project
* Add helpers to further type PlanTypes
* Enable testing of ASP.net MVC controllers
Controller properties have all kinds of validations in the background.
In general, we don't user properties on our Controllers, so the easiest
way to allow for Autofixture-based testing of our Controllers is to just
omit setting all properties on them.
* Workaround for broken MemberAutoDataAttribute
https://github.com/AutoFixture/AutoFixture/pull/1164 shows that only
the first test case is pulled for this attribute.
This is a workaround that populates the provided parameters, left to
right, using AutoFixture to populate any remaining.
* WIP: Organization sponsorship flow
* Add Attribute to use the Bit Autodata dependency chain
BitAutoDataAttribute is used to mark a Theory as autopopulating
parameters.
Extract common attribute methods to to a helper class. Cannot
inherit a common base, since both require inheriting from different
Xunit base classes to work.
* WIP: scaffolding for families for enterprise sponsorship flow
* Fix broken tests
* Create sponsorship offer (#1688)
* Initial db work (#1687)
* Add organization sponsorship databases to all providers
* Generalize create and update for database, specialize in code
* Add PlanSponsorshipType to db model
* Write valid json for test entries
* Initial scaffolding of emails (#1686)
* Initial scaffolding of emails
* Work on adding models for FamilyForEnterprise emails
* Switch verbage
* Put preliminary copy in emails
* Skip test
* Families for enterprise/stripe integrations (#1699)
* Add PlanSponsorshipType to static store
* Add sponsorship type to token and creates sponsorship
* PascalCase properties
* Require sponsorship for remove
* Create subscription sponsorship helper class
* Handle Sponsored subscription changes
* Add sponsorship id to subscription metadata
* Make sponsoring references nullable
This state indicates that a sponsorship has lapsed, but was not able to
be reverted for billing reasons
* WIP: Validate and remove subscriptions
* Update sponsorships on organization and org user delete
* Add friendly name to organization sponsorship
* Add sponsorship available boolean to orgDetails
* Add sponsorship service to DI
* Use userId to find org users
* Send f4e offer email
* Simplify names of f4e mail messages
* Fix Stripe org default tax rates
* Universal sponsorship redeem api
* Populate user in current context
* Add product type to organization details
* Use upgrade path to change sponsorship
Sponsorships need to be annual to match the GB add-on charge rate
* Use organization and auth to find organization sponsorship
* Add resend sponsorship offer api endpoint
* Fix double email send
* Fix sponsorship upgrade options
* Add is sponsored item to subscription response
* Add sponsorship validation to upcoming invoice webhook
* Add sponsorship validation to upcoming invoice webhook
* Fix organization delete sponsorship hooks
* Test org sponsorship service
* Fix sproc
* Create common test infrastructure project
* Add helpers to further type PlanTypes
* Enable testing of ASP.net MVC controllers
Controller properties have all kinds of validations in the background.
In general, we don't user properties on our Controllers, so the easiest
way to allow for Autofixture-based testing of our Controllers is to just
omit setting all properties on them.
* Workaround for broken MemberAutoDataAttribute
https://github.com/AutoFixture/AutoFixture/pull/1164 shows that only
the first test case is pulled for this attribute.
This is a workaround that populates the provided parameters, left to
right, using AutoFixture to populate any remaining.
* WIP: Organization sponsorship flow
* Add Attribute to use the Bit Autodata dependency chain
BitAutoDataAttribute is used to mark a Theory as autopopulating
parameters.
Extract common attribute methods to to a helper class. Cannot
inherit a common base, since both require inheriting from different
Xunit base classes to work.
* WIP: scaffolding for families for enterprise sponsorship flow
* Fix broken tests
* Create sponsorship offer (#1688)
* Initial db work (#1687)
* Add organization sponsorship databases to all providers
* Generalize create and update for database, specialize in code
* Add PlanSponsorshipType to db model
* Write valid json for test entries
* Initial scaffolding of emails (#1686)
* Initial scaffolding of emails
* Work on adding models for FamilyForEnterprise emails
* Switch verbage
* Put preliminary copy in emails
* Skip test
* Families for enterprise/stripe integrations (#1699)
* Add PlanSponsorshipType to static store
* Add sponsorship type to token and creates sponsorship
* PascalCase properties
* Require sponsorship for remove
* Create subscription sponsorship helper class
* Handle Sponsored subscription changes
* Add sponsorship id to subscription metadata
* Make sponsoring references nullable
This state indicates that a sponsorship has lapsed, but was not able to
be reverted for billing reasons
* WIP: Validate and remove subscriptions
* Update sponsorships on organization and org user delete
* Add friendly name to organization sponsorship
* Add sponsorship available boolean to orgDetails
* Add sponsorship service to DI
* Use userId to find org users
* Send f4e offer email
* Simplify names of f4e mail messages
* Fix Stripe org default tax rates
* Universal sponsorship redeem api
* Populate user in current context
* Add product type to organization details
* Use upgrade path to change sponsorship
Sponsorships need to be annual to match the GB add-on charge rate
* Use organization and auth to find organization sponsorship
* Add resend sponsorship offer api endpoint
* Fix double email send
* Fix sponsorship upgrade options
* Add is sponsored item to subscription response
* Add sponsorship validation to upcoming invoice webhook
* Add sponsorship validation to upcoming invoice webhook
* Fix organization delete sponsorship hooks
* Test org sponsorship service
* Fix sproc
* Fix build error
* Update emails
* Fix tests
* Skip local test
* Add newline
* Fix stripe subscription update
* Finish emails
* Skip test
* Fix unit tests
* Remove unused variable
* Fix unit tests
* Switch to handlebars ifs
* Remove ending email
* Remove reconfirmation template
* Switch naming convention
* Switch naming convention
* Fix migration
* Update copy and links
* Switch to using Guid in the method
* Remove unneeded css styles
* Add sql files to Sql.sqlproj
* Removed old comments
* Made name more verbose
* Fix SQL error
* Move unit tests to service
* Fix sp
* Revert "Move unit tests to service"
This reverts commit 1185bf3ec8ca36ccd75717ed2463adf8885159a6.
* Do repository validation in service layer
* Fix tests
* Fix merge conflicts and remove TODO
* Remove unneeded models
* Fix spacing and formatting
* Switch Org -> Organization
* Remove single use variables
* Switch method name
* Fix Controller
* Switch to obfuscating email
* Fix unit tests
Co-authored-by: Justin Baur <admin@justinbaur.com>
2021-11-19 16:25:06 -06:00
|
|
|
|
|
|
|
|
|
|
public async Task SendProviderUserRemoved(string providerName, string email)
|
2022-08-29 15:53:48 -04:00
|
|
|
|
{
|
Families for Enterprise (#1714)
* Create common test infrastructure project
* Add helpers to further type PlanTypes
* Enable testing of ASP.net MVC controllers
Controller properties have all kinds of validations in the background.
In general, we don't user properties on our Controllers, so the easiest
way to allow for Autofixture-based testing of our Controllers is to just
omit setting all properties on them.
* Workaround for broken MemberAutoDataAttribute
https://github.com/AutoFixture/AutoFixture/pull/1164 shows that only
the first test case is pulled for this attribute.
This is a workaround that populates the provided parameters, left to
right, using AutoFixture to populate any remaining.
* WIP: Organization sponsorship flow
* Add Attribute to use the Bit Autodata dependency chain
BitAutoDataAttribute is used to mark a Theory as autopopulating
parameters.
Extract common attribute methods to to a helper class. Cannot
inherit a common base, since both require inheriting from different
Xunit base classes to work.
* WIP: scaffolding for families for enterprise sponsorship flow
* Fix broken tests
* Create sponsorship offer (#1688)
* Initial db work (#1687)
* Add organization sponsorship databases to all providers
* Generalize create and update for database, specialize in code
* Add PlanSponsorshipType to db model
* Write valid json for test entries
* Initial scaffolding of emails (#1686)
* Initial scaffolding of emails
* Work on adding models for FamilyForEnterprise emails
* Switch verbage
* Put preliminary copy in emails
* Skip test
* Families for enterprise/stripe integrations (#1699)
* Add PlanSponsorshipType to static store
* Add sponsorship type to token and creates sponsorship
* PascalCase properties
* Require sponsorship for remove
* Create subscription sponsorship helper class
* Handle Sponsored subscription changes
* Add sponsorship id to subscription metadata
* Make sponsoring references nullable
This state indicates that a sponsorship has lapsed, but was not able to
be reverted for billing reasons
* WIP: Validate and remove subscriptions
* Update sponsorships on organization and org user delete
* Add friendly name to organization sponsorship
* Add sponsorship available boolean to orgDetails
* Add sponsorship service to DI
* Use userId to find org users
* Send f4e offer email
* Simplify names of f4e mail messages
* Fix Stripe org default tax rates
* Universal sponsorship redeem api
* Populate user in current context
* Add product type to organization details
* Use upgrade path to change sponsorship
Sponsorships need to be annual to match the GB add-on charge rate
* Use organization and auth to find organization sponsorship
* Add resend sponsorship offer api endpoint
* Fix double email send
* Fix sponsorship upgrade options
* Add is sponsored item to subscription response
* Add sponsorship validation to upcoming invoice webhook
* Add sponsorship validation to upcoming invoice webhook
* Fix organization delete sponsorship hooks
* Test org sponsorship service
* Fix sproc
* Create common test infrastructure project
* Add helpers to further type PlanTypes
* Enable testing of ASP.net MVC controllers
Controller properties have all kinds of validations in the background.
In general, we don't user properties on our Controllers, so the easiest
way to allow for Autofixture-based testing of our Controllers is to just
omit setting all properties on them.
* Workaround for broken MemberAutoDataAttribute
https://github.com/AutoFixture/AutoFixture/pull/1164 shows that only
the first test case is pulled for this attribute.
This is a workaround that populates the provided parameters, left to
right, using AutoFixture to populate any remaining.
* WIP: Organization sponsorship flow
* Add Attribute to use the Bit Autodata dependency chain
BitAutoDataAttribute is used to mark a Theory as autopopulating
parameters.
Extract common attribute methods to to a helper class. Cannot
inherit a common base, since both require inheriting from different
Xunit base classes to work.
* WIP: scaffolding for families for enterprise sponsorship flow
* Fix broken tests
* Create sponsorship offer (#1688)
* Initial db work (#1687)
* Add organization sponsorship databases to all providers
* Generalize create and update for database, specialize in code
* Add PlanSponsorshipType to db model
* Write valid json for test entries
* Initial scaffolding of emails (#1686)
* Initial scaffolding of emails
* Work on adding models for FamilyForEnterprise emails
* Switch verbage
* Put preliminary copy in emails
* Skip test
* Families for enterprise/stripe integrations (#1699)
* Add PlanSponsorshipType to static store
* Add sponsorship type to token and creates sponsorship
* PascalCase properties
* Require sponsorship for remove
* Create subscription sponsorship helper class
* Handle Sponsored subscription changes
* Add sponsorship id to subscription metadata
* Make sponsoring references nullable
This state indicates that a sponsorship has lapsed, but was not able to
be reverted for billing reasons
* WIP: Validate and remove subscriptions
* Update sponsorships on organization and org user delete
* Add friendly name to organization sponsorship
* Add sponsorship available boolean to orgDetails
* Add sponsorship service to DI
* Use userId to find org users
* Send f4e offer email
* Simplify names of f4e mail messages
* Fix Stripe org default tax rates
* Universal sponsorship redeem api
* Populate user in current context
* Add product type to organization details
* Use upgrade path to change sponsorship
Sponsorships need to be annual to match the GB add-on charge rate
* Use organization and auth to find organization sponsorship
* Add resend sponsorship offer api endpoint
* Fix double email send
* Fix sponsorship upgrade options
* Add is sponsored item to subscription response
* Add sponsorship validation to upcoming invoice webhook
* Add sponsorship validation to upcoming invoice webhook
* Fix organization delete sponsorship hooks
* Test org sponsorship service
* Fix sproc
* Fix build error
* Update emails
* Fix tests
* Skip local test
* Add newline
* Fix stripe subscription update
* Finish emails
* Skip test
* Fix unit tests
* Remove unused variable
* Fix unit tests
* Switch to handlebars ifs
* Remove ending email
* Remove reconfirmation template
* Switch naming convention
* Switch naming convention
* Fix migration
* Update copy and links
* Switch to using Guid in the method
* Remove unneeded css styles
* Add sql files to Sql.sqlproj
* Removed old comments
* Made name more verbose
* Fix SQL error
* Move unit tests to service
* Fix sp
* Revert "Move unit tests to service"
This reverts commit 1185bf3ec8ca36ccd75717ed2463adf8885159a6.
* Do repository validation in service layer
* Fix tests
* Fix merge conflicts and remove TODO
* Remove unneeded models
* Fix spacing and formatting
* Switch Org -> Organization
* Remove single use variables
* Switch method name
* Fix Controller
* Switch to obfuscating email
* Fix unit tests
Co-authored-by: Justin Baur <admin@justinbaur.com>
2021-11-19 16:25:06 -06:00
|
|
|
|
var message = CreateDefaultMessage($"You Have Been Removed from {providerName}", email);
|
|
|
|
|
|
var model = new ProviderUserRemovedViewModel
|
2022-08-29 15:53:48 -04:00
|
|
|
|
{
|
Families for Enterprise (#1714)
* Create common test infrastructure project
* Add helpers to further type PlanTypes
* Enable testing of ASP.net MVC controllers
Controller properties have all kinds of validations in the background.
In general, we don't user properties on our Controllers, so the easiest
way to allow for Autofixture-based testing of our Controllers is to just
omit setting all properties on them.
* Workaround for broken MemberAutoDataAttribute
https://github.com/AutoFixture/AutoFixture/pull/1164 shows that only
the first test case is pulled for this attribute.
This is a workaround that populates the provided parameters, left to
right, using AutoFixture to populate any remaining.
* WIP: Organization sponsorship flow
* Add Attribute to use the Bit Autodata dependency chain
BitAutoDataAttribute is used to mark a Theory as autopopulating
parameters.
Extract common attribute methods to to a helper class. Cannot
inherit a common base, since both require inheriting from different
Xunit base classes to work.
* WIP: scaffolding for families for enterprise sponsorship flow
* Fix broken tests
* Create sponsorship offer (#1688)
* Initial db work (#1687)
* Add organization sponsorship databases to all providers
* Generalize create and update for database, specialize in code
* Add PlanSponsorshipType to db model
* Write valid json for test entries
* Initial scaffolding of emails (#1686)
* Initial scaffolding of emails
* Work on adding models for FamilyForEnterprise emails
* Switch verbage
* Put preliminary copy in emails
* Skip test
* Families for enterprise/stripe integrations (#1699)
* Add PlanSponsorshipType to static store
* Add sponsorship type to token and creates sponsorship
* PascalCase properties
* Require sponsorship for remove
* Create subscription sponsorship helper class
* Handle Sponsored subscription changes
* Add sponsorship id to subscription metadata
* Make sponsoring references nullable
This state indicates that a sponsorship has lapsed, but was not able to
be reverted for billing reasons
* WIP: Validate and remove subscriptions
* Update sponsorships on organization and org user delete
* Add friendly name to organization sponsorship
* Add sponsorship available boolean to orgDetails
* Add sponsorship service to DI
* Use userId to find org users
* Send f4e offer email
* Simplify names of f4e mail messages
* Fix Stripe org default tax rates
* Universal sponsorship redeem api
* Populate user in current context
* Add product type to organization details
* Use upgrade path to change sponsorship
Sponsorships need to be annual to match the GB add-on charge rate
* Use organization and auth to find organization sponsorship
* Add resend sponsorship offer api endpoint
* Fix double email send
* Fix sponsorship upgrade options
* Add is sponsored item to subscription response
* Add sponsorship validation to upcoming invoice webhook
* Add sponsorship validation to upcoming invoice webhook
* Fix organization delete sponsorship hooks
* Test org sponsorship service
* Fix sproc
* Create common test infrastructure project
* Add helpers to further type PlanTypes
* Enable testing of ASP.net MVC controllers
Controller properties have all kinds of validations in the background.
In general, we don't user properties on our Controllers, so the easiest
way to allow for Autofixture-based testing of our Controllers is to just
omit setting all properties on them.
* Workaround for broken MemberAutoDataAttribute
https://github.com/AutoFixture/AutoFixture/pull/1164 shows that only
the first test case is pulled for this attribute.
This is a workaround that populates the provided parameters, left to
right, using AutoFixture to populate any remaining.
* WIP: Organization sponsorship flow
* Add Attribute to use the Bit Autodata dependency chain
BitAutoDataAttribute is used to mark a Theory as autopopulating
parameters.
Extract common attribute methods to to a helper class. Cannot
inherit a common base, since both require inheriting from different
Xunit base classes to work.
* WIP: scaffolding for families for enterprise sponsorship flow
* Fix broken tests
* Create sponsorship offer (#1688)
* Initial db work (#1687)
* Add organization sponsorship databases to all providers
* Generalize create and update for database, specialize in code
* Add PlanSponsorshipType to db model
* Write valid json for test entries
* Initial scaffolding of emails (#1686)
* Initial scaffolding of emails
* Work on adding models for FamilyForEnterprise emails
* Switch verbage
* Put preliminary copy in emails
* Skip test
* Families for enterprise/stripe integrations (#1699)
* Add PlanSponsorshipType to static store
* Add sponsorship type to token and creates sponsorship
* PascalCase properties
* Require sponsorship for remove
* Create subscription sponsorship helper class
* Handle Sponsored subscription changes
* Add sponsorship id to subscription metadata
* Make sponsoring references nullable
This state indicates that a sponsorship has lapsed, but was not able to
be reverted for billing reasons
* WIP: Validate and remove subscriptions
* Update sponsorships on organization and org user delete
* Add friendly name to organization sponsorship
* Add sponsorship available boolean to orgDetails
* Add sponsorship service to DI
* Use userId to find org users
* Send f4e offer email
* Simplify names of f4e mail messages
* Fix Stripe org default tax rates
* Universal sponsorship redeem api
* Populate user in current context
* Add product type to organization details
* Use upgrade path to change sponsorship
Sponsorships need to be annual to match the GB add-on charge rate
* Use organization and auth to find organization sponsorship
* Add resend sponsorship offer api endpoint
* Fix double email send
* Fix sponsorship upgrade options
* Add is sponsored item to subscription response
* Add sponsorship validation to upcoming invoice webhook
* Add sponsorship validation to upcoming invoice webhook
* Fix organization delete sponsorship hooks
* Test org sponsorship service
* Fix sproc
* Fix build error
* Update emails
* Fix tests
* Skip local test
* Add newline
* Fix stripe subscription update
* Finish emails
* Skip test
* Fix unit tests
* Remove unused variable
* Fix unit tests
* Switch to handlebars ifs
* Remove ending email
* Remove reconfirmation template
* Switch naming convention
* Switch naming convention
* Fix migration
* Update copy and links
* Switch to using Guid in the method
* Remove unneeded css styles
* Add sql files to Sql.sqlproj
* Removed old comments
* Made name more verbose
* Fix SQL error
* Move unit tests to service
* Fix sp
* Revert "Move unit tests to service"
This reverts commit 1185bf3ec8ca36ccd75717ed2463adf8885159a6.
* Do repository validation in service layer
* Fix tests
* Fix merge conflicts and remove TODO
* Remove unneeded models
* Fix spacing and formatting
* Switch Org -> Organization
* Remove single use variables
* Switch method name
* Fix Controller
* Switch to obfuscating email
* Fix unit tests
Co-authored-by: Justin Baur <admin@justinbaur.com>
2021-11-19 16:25:06 -06:00
|
|
|
|
ProviderName = CoreHelpers.SanitizeForEmail(providerName),
|
|
|
|
|
|
WebVaultUrl = _globalSettings.BaseServiceUri.VaultWithHash,
|
|
|
|
|
|
SiteName = _globalSettings.SiteName
|
2022-08-29 15:53:48 -04:00
|
|
|
|
};
|
Families for Enterprise (#1714)
* Create common test infrastructure project
* Add helpers to further type PlanTypes
* Enable testing of ASP.net MVC controllers
Controller properties have all kinds of validations in the background.
In general, we don't user properties on our Controllers, so the easiest
way to allow for Autofixture-based testing of our Controllers is to just
omit setting all properties on them.
* Workaround for broken MemberAutoDataAttribute
https://github.com/AutoFixture/AutoFixture/pull/1164 shows that only
the first test case is pulled for this attribute.
This is a workaround that populates the provided parameters, left to
right, using AutoFixture to populate any remaining.
* WIP: Organization sponsorship flow
* Add Attribute to use the Bit Autodata dependency chain
BitAutoDataAttribute is used to mark a Theory as autopopulating
parameters.
Extract common attribute methods to to a helper class. Cannot
inherit a common base, since both require inheriting from different
Xunit base classes to work.
* WIP: scaffolding for families for enterprise sponsorship flow
* Fix broken tests
* Create sponsorship offer (#1688)
* Initial db work (#1687)
* Add organization sponsorship databases to all providers
* Generalize create and update for database, specialize in code
* Add PlanSponsorshipType to db model
* Write valid json for test entries
* Initial scaffolding of emails (#1686)
* Initial scaffolding of emails
* Work on adding models for FamilyForEnterprise emails
* Switch verbage
* Put preliminary copy in emails
* Skip test
* Families for enterprise/stripe integrations (#1699)
* Add PlanSponsorshipType to static store
* Add sponsorship type to token and creates sponsorship
* PascalCase properties
* Require sponsorship for remove
* Create subscription sponsorship helper class
* Handle Sponsored subscription changes
* Add sponsorship id to subscription metadata
* Make sponsoring references nullable
This state indicates that a sponsorship has lapsed, but was not able to
be reverted for billing reasons
* WIP: Validate and remove subscriptions
* Update sponsorships on organization and org user delete
* Add friendly name to organization sponsorship
* Add sponsorship available boolean to orgDetails
* Add sponsorship service to DI
* Use userId to find org users
* Send f4e offer email
* Simplify names of f4e mail messages
* Fix Stripe org default tax rates
* Universal sponsorship redeem api
* Populate user in current context
* Add product type to organization details
* Use upgrade path to change sponsorship
Sponsorships need to be annual to match the GB add-on charge rate
* Use organization and auth to find organization sponsorship
* Add resend sponsorship offer api endpoint
* Fix double email send
* Fix sponsorship upgrade options
* Add is sponsored item to subscription response
* Add sponsorship validation to upcoming invoice webhook
* Add sponsorship validation to upcoming invoice webhook
* Fix organization delete sponsorship hooks
* Test org sponsorship service
* Fix sproc
* Create common test infrastructure project
* Add helpers to further type PlanTypes
* Enable testing of ASP.net MVC controllers
Controller properties have all kinds of validations in the background.
In general, we don't user properties on our Controllers, so the easiest
way to allow for Autofixture-based testing of our Controllers is to just
omit setting all properties on them.
* Workaround for broken MemberAutoDataAttribute
https://github.com/AutoFixture/AutoFixture/pull/1164 shows that only
the first test case is pulled for this attribute.
This is a workaround that populates the provided parameters, left to
right, using AutoFixture to populate any remaining.
* WIP: Organization sponsorship flow
* Add Attribute to use the Bit Autodata dependency chain
BitAutoDataAttribute is used to mark a Theory as autopopulating
parameters.
Extract common attribute methods to to a helper class. Cannot
inherit a common base, since both require inheriting from different
Xunit base classes to work.
* WIP: scaffolding for families for enterprise sponsorship flow
* Fix broken tests
* Create sponsorship offer (#1688)
* Initial db work (#1687)
* Add organization sponsorship databases to all providers
* Generalize create and update for database, specialize in code
* Add PlanSponsorshipType to db model
* Write valid json for test entries
* Initial scaffolding of emails (#1686)
* Initial scaffolding of emails
* Work on adding models for FamilyForEnterprise emails
* Switch verbage
* Put preliminary copy in emails
* Skip test
* Families for enterprise/stripe integrations (#1699)
* Add PlanSponsorshipType to static store
* Add sponsorship type to token and creates sponsorship
* PascalCase properties
* Require sponsorship for remove
* Create subscription sponsorship helper class
* Handle Sponsored subscription changes
* Add sponsorship id to subscription metadata
* Make sponsoring references nullable
This state indicates that a sponsorship has lapsed, but was not able to
be reverted for billing reasons
* WIP: Validate and remove subscriptions
* Update sponsorships on organization and org user delete
* Add friendly name to organization sponsorship
* Add sponsorship available boolean to orgDetails
* Add sponsorship service to DI
* Use userId to find org users
* Send f4e offer email
* Simplify names of f4e mail messages
* Fix Stripe org default tax rates
* Universal sponsorship redeem api
* Populate user in current context
* Add product type to organization details
* Use upgrade path to change sponsorship
Sponsorships need to be annual to match the GB add-on charge rate
* Use organization and auth to find organization sponsorship
* Add resend sponsorship offer api endpoint
* Fix double email send
* Fix sponsorship upgrade options
* Add is sponsored item to subscription response
* Add sponsorship validation to upcoming invoice webhook
* Add sponsorship validation to upcoming invoice webhook
* Fix organization delete sponsorship hooks
* Test org sponsorship service
* Fix sproc
* Fix build error
* Update emails
* Fix tests
* Skip local test
* Add newline
* Fix stripe subscription update
* Finish emails
* Skip test
* Fix unit tests
* Remove unused variable
* Fix unit tests
* Switch to handlebars ifs
* Remove ending email
* Remove reconfirmation template
* Switch naming convention
* Switch naming convention
* Fix migration
* Update copy and links
* Switch to using Guid in the method
* Remove unneeded css styles
* Add sql files to Sql.sqlproj
* Removed old comments
* Made name more verbose
* Fix SQL error
* Move unit tests to service
* Fix sp
* Revert "Move unit tests to service"
This reverts commit 1185bf3ec8ca36ccd75717ed2463adf8885159a6.
* Do repository validation in service layer
* Fix tests
* Fix merge conflicts and remove TODO
* Remove unneeded models
* Fix spacing and formatting
* Switch Org -> Organization
* Remove single use variables
* Switch method name
* Fix Controller
* Switch to obfuscating email
* Fix unit tests
Co-authored-by: Justin Baur <admin@justinbaur.com>
2021-11-19 16:25:06 -06:00
|
|
|
|
await AddMessageContentAsync(message, "Provider.ProviderUserRemoved", model);
|
2022-03-02 15:45:00 -06:00
|
|
|
|
message.Category = "ProviderUserRemoved";
|
Families for Enterprise (#1714)
* Create common test infrastructure project
* Add helpers to further type PlanTypes
* Enable testing of ASP.net MVC controllers
Controller properties have all kinds of validations in the background.
In general, we don't user properties on our Controllers, so the easiest
way to allow for Autofixture-based testing of our Controllers is to just
omit setting all properties on them.
* Workaround for broken MemberAutoDataAttribute
https://github.com/AutoFixture/AutoFixture/pull/1164 shows that only
the first test case is pulled for this attribute.
This is a workaround that populates the provided parameters, left to
right, using AutoFixture to populate any remaining.
* WIP: Organization sponsorship flow
* Add Attribute to use the Bit Autodata dependency chain
BitAutoDataAttribute is used to mark a Theory as autopopulating
parameters.
Extract common attribute methods to to a helper class. Cannot
inherit a common base, since both require inheriting from different
Xunit base classes to work.
* WIP: scaffolding for families for enterprise sponsorship flow
* Fix broken tests
* Create sponsorship offer (#1688)
* Initial db work (#1687)
* Add organization sponsorship databases to all providers
* Generalize create and update for database, specialize in code
* Add PlanSponsorshipType to db model
* Write valid json for test entries
* Initial scaffolding of emails (#1686)
* Initial scaffolding of emails
* Work on adding models for FamilyForEnterprise emails
* Switch verbage
* Put preliminary copy in emails
* Skip test
* Families for enterprise/stripe integrations (#1699)
* Add PlanSponsorshipType to static store
* Add sponsorship type to token and creates sponsorship
* PascalCase properties
* Require sponsorship for remove
* Create subscription sponsorship helper class
* Handle Sponsored subscription changes
* Add sponsorship id to subscription metadata
* Make sponsoring references nullable
This state indicates that a sponsorship has lapsed, but was not able to
be reverted for billing reasons
* WIP: Validate and remove subscriptions
* Update sponsorships on organization and org user delete
* Add friendly name to organization sponsorship
* Add sponsorship available boolean to orgDetails
* Add sponsorship service to DI
* Use userId to find org users
* Send f4e offer email
* Simplify names of f4e mail messages
* Fix Stripe org default tax rates
* Universal sponsorship redeem api
* Populate user in current context
* Add product type to organization details
* Use upgrade path to change sponsorship
Sponsorships need to be annual to match the GB add-on charge rate
* Use organization and auth to find organization sponsorship
* Add resend sponsorship offer api endpoint
* Fix double email send
* Fix sponsorship upgrade options
* Add is sponsored item to subscription response
* Add sponsorship validation to upcoming invoice webhook
* Add sponsorship validation to upcoming invoice webhook
* Fix organization delete sponsorship hooks
* Test org sponsorship service
* Fix sproc
* Create common test infrastructure project
* Add helpers to further type PlanTypes
* Enable testing of ASP.net MVC controllers
Controller properties have all kinds of validations in the background.
In general, we don't user properties on our Controllers, so the easiest
way to allow for Autofixture-based testing of our Controllers is to just
omit setting all properties on them.
* Workaround for broken MemberAutoDataAttribute
https://github.com/AutoFixture/AutoFixture/pull/1164 shows that only
the first test case is pulled for this attribute.
This is a workaround that populates the provided parameters, left to
right, using AutoFixture to populate any remaining.
* WIP: Organization sponsorship flow
* Add Attribute to use the Bit Autodata dependency chain
BitAutoDataAttribute is used to mark a Theory as autopopulating
parameters.
Extract common attribute methods to to a helper class. Cannot
inherit a common base, since both require inheriting from different
Xunit base classes to work.
* WIP: scaffolding for families for enterprise sponsorship flow
* Fix broken tests
* Create sponsorship offer (#1688)
* Initial db work (#1687)
* Add organization sponsorship databases to all providers
* Generalize create and update for database, specialize in code
* Add PlanSponsorshipType to db model
* Write valid json for test entries
* Initial scaffolding of emails (#1686)
* Initial scaffolding of emails
* Work on adding models for FamilyForEnterprise emails
* Switch verbage
* Put preliminary copy in emails
* Skip test
* Families for enterprise/stripe integrations (#1699)
* Add PlanSponsorshipType to static store
* Add sponsorship type to token and creates sponsorship
* PascalCase properties
* Require sponsorship for remove
* Create subscription sponsorship helper class
* Handle Sponsored subscription changes
* Add sponsorship id to subscription metadata
* Make sponsoring references nullable
This state indicates that a sponsorship has lapsed, but was not able to
be reverted for billing reasons
* WIP: Validate and remove subscriptions
* Update sponsorships on organization and org user delete
* Add friendly name to organization sponsorship
* Add sponsorship available boolean to orgDetails
* Add sponsorship service to DI
* Use userId to find org users
* Send f4e offer email
* Simplify names of f4e mail messages
* Fix Stripe org default tax rates
* Universal sponsorship redeem api
* Populate user in current context
* Add product type to organization details
* Use upgrade path to change sponsorship
Sponsorships need to be annual to match the GB add-on charge rate
* Use organization and auth to find organization sponsorship
* Add resend sponsorship offer api endpoint
* Fix double email send
* Fix sponsorship upgrade options
* Add is sponsored item to subscription response
* Add sponsorship validation to upcoming invoice webhook
* Add sponsorship validation to upcoming invoice webhook
* Fix organization delete sponsorship hooks
* Test org sponsorship service
* Fix sproc
* Fix build error
* Update emails
* Fix tests
* Skip local test
* Add newline
* Fix stripe subscription update
* Finish emails
* Skip test
* Fix unit tests
* Remove unused variable
* Fix unit tests
* Switch to handlebars ifs
* Remove ending email
* Remove reconfirmation template
* Switch naming convention
* Switch naming convention
* Fix migration
* Update copy and links
* Switch to using Guid in the method
* Remove unneeded css styles
* Add sql files to Sql.sqlproj
* Removed old comments
* Made name more verbose
* Fix SQL error
* Move unit tests to service
* Fix sp
* Revert "Move unit tests to service"
This reverts commit 1185bf3ec8ca36ccd75717ed2463adf8885159a6.
* Do repository validation in service layer
* Fix tests
* Fix merge conflicts and remove TODO
* Remove unneeded models
* Fix spacing and formatting
* Switch Org -> Organization
* Remove single use variables
* Switch method name
* Fix Controller
* Switch to obfuscating email
* Fix unit tests
Co-authored-by: Justin Baur <admin@justinbaur.com>
2021-11-19 16:25:06 -06:00
|
|
|
|
await _mailDeliveryService.SendEmailAsync(message);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public async Task SendUpdatedTempPasswordEmailAsync(string email, string userName)
|
2022-08-29 16:06:55 -04:00
|
|
|
|
{
|
Families for Enterprise (#1714)
* Create common test infrastructure project
* Add helpers to further type PlanTypes
* Enable testing of ASP.net MVC controllers
Controller properties have all kinds of validations in the background.
In general, we don't user properties on our Controllers, so the easiest
way to allow for Autofixture-based testing of our Controllers is to just
omit setting all properties on them.
* Workaround for broken MemberAutoDataAttribute
https://github.com/AutoFixture/AutoFixture/pull/1164 shows that only
the first test case is pulled for this attribute.
This is a workaround that populates the provided parameters, left to
right, using AutoFixture to populate any remaining.
* WIP: Organization sponsorship flow
* Add Attribute to use the Bit Autodata dependency chain
BitAutoDataAttribute is used to mark a Theory as autopopulating
parameters.
Extract common attribute methods to to a helper class. Cannot
inherit a common base, since both require inheriting from different
Xunit base classes to work.
* WIP: scaffolding for families for enterprise sponsorship flow
* Fix broken tests
* Create sponsorship offer (#1688)
* Initial db work (#1687)
* Add organization sponsorship databases to all providers
* Generalize create and update for database, specialize in code
* Add PlanSponsorshipType to db model
* Write valid json for test entries
* Initial scaffolding of emails (#1686)
* Initial scaffolding of emails
* Work on adding models for FamilyForEnterprise emails
* Switch verbage
* Put preliminary copy in emails
* Skip test
* Families for enterprise/stripe integrations (#1699)
* Add PlanSponsorshipType to static store
* Add sponsorship type to token and creates sponsorship
* PascalCase properties
* Require sponsorship for remove
* Create subscription sponsorship helper class
* Handle Sponsored subscription changes
* Add sponsorship id to subscription metadata
* Make sponsoring references nullable
This state indicates that a sponsorship has lapsed, but was not able to
be reverted for billing reasons
* WIP: Validate and remove subscriptions
* Update sponsorships on organization and org user delete
* Add friendly name to organization sponsorship
* Add sponsorship available boolean to orgDetails
* Add sponsorship service to DI
* Use userId to find org users
* Send f4e offer email
* Simplify names of f4e mail messages
* Fix Stripe org default tax rates
* Universal sponsorship redeem api
* Populate user in current context
* Add product type to organization details
* Use upgrade path to change sponsorship
Sponsorships need to be annual to match the GB add-on charge rate
* Use organization and auth to find organization sponsorship
* Add resend sponsorship offer api endpoint
* Fix double email send
* Fix sponsorship upgrade options
* Add is sponsored item to subscription response
* Add sponsorship validation to upcoming invoice webhook
* Add sponsorship validation to upcoming invoice webhook
* Fix organization delete sponsorship hooks
* Test org sponsorship service
* Fix sproc
* Create common test infrastructure project
* Add helpers to further type PlanTypes
* Enable testing of ASP.net MVC controllers
Controller properties have all kinds of validations in the background.
In general, we don't user properties on our Controllers, so the easiest
way to allow for Autofixture-based testing of our Controllers is to just
omit setting all properties on them.
* Workaround for broken MemberAutoDataAttribute
https://github.com/AutoFixture/AutoFixture/pull/1164 shows that only
the first test case is pulled for this attribute.
This is a workaround that populates the provided parameters, left to
right, using AutoFixture to populate any remaining.
* WIP: Organization sponsorship flow
* Add Attribute to use the Bit Autodata dependency chain
BitAutoDataAttribute is used to mark a Theory as autopopulating
parameters.
Extract common attribute methods to to a helper class. Cannot
inherit a common base, since both require inheriting from different
Xunit base classes to work.
* WIP: scaffolding for families for enterprise sponsorship flow
* Fix broken tests
* Create sponsorship offer (#1688)
* Initial db work (#1687)
* Add organization sponsorship databases to all providers
* Generalize create and update for database, specialize in code
* Add PlanSponsorshipType to db model
* Write valid json for test entries
* Initial scaffolding of emails (#1686)
* Initial scaffolding of emails
* Work on adding models for FamilyForEnterprise emails
* Switch verbage
* Put preliminary copy in emails
* Skip test
* Families for enterprise/stripe integrations (#1699)
* Add PlanSponsorshipType to static store
* Add sponsorship type to token and creates sponsorship
* PascalCase properties
* Require sponsorship for remove
* Create subscription sponsorship helper class
* Handle Sponsored subscription changes
* Add sponsorship id to subscription metadata
* Make sponsoring references nullable
This state indicates that a sponsorship has lapsed, but was not able to
be reverted for billing reasons
* WIP: Validate and remove subscriptions
* Update sponsorships on organization and org user delete
* Add friendly name to organization sponsorship
* Add sponsorship available boolean to orgDetails
* Add sponsorship service to DI
* Use userId to find org users
* Send f4e offer email
* Simplify names of f4e mail messages
* Fix Stripe org default tax rates
* Universal sponsorship redeem api
* Populate user in current context
* Add product type to organization details
* Use upgrade path to change sponsorship
Sponsorships need to be annual to match the GB add-on charge rate
* Use organization and auth to find organization sponsorship
* Add resend sponsorship offer api endpoint
* Fix double email send
* Fix sponsorship upgrade options
* Add is sponsored item to subscription response
* Add sponsorship validation to upcoming invoice webhook
* Add sponsorship validation to upcoming invoice webhook
* Fix organization delete sponsorship hooks
* Test org sponsorship service
* Fix sproc
* Fix build error
* Update emails
* Fix tests
* Skip local test
* Add newline
* Fix stripe subscription update
* Finish emails
* Skip test
* Fix unit tests
* Remove unused variable
* Fix unit tests
* Switch to handlebars ifs
* Remove ending email
* Remove reconfirmation template
* Switch naming convention
* Switch naming convention
* Fix migration
* Update copy and links
* Switch to using Guid in the method
* Remove unneeded css styles
* Add sql files to Sql.sqlproj
* Removed old comments
* Made name more verbose
* Fix SQL error
* Move unit tests to service
* Fix sp
* Revert "Move unit tests to service"
This reverts commit 1185bf3ec8ca36ccd75717ed2463adf8885159a6.
* Do repository validation in service layer
* Fix tests
* Fix merge conflicts and remove TODO
* Remove unneeded models
* Fix spacing and formatting
* Switch Org -> Organization
* Remove single use variables
* Switch method name
* Fix Controller
* Switch to obfuscating email
* Fix unit tests
Co-authored-by: Justin Baur <admin@justinbaur.com>
2021-11-19 16:25:06 -06:00
|
|
|
|
var message = CreateDefaultMessage("Master Password Has Been Changed", email);
|
|
|
|
|
|
var model = new UpdateTempPasswordViewModel()
|
|
|
|
|
|
{
|
|
|
|
|
|
UserName = GetUserIdentifier(email, userName)
|
|
|
|
|
|
};
|
|
|
|
|
|
await AddMessageContentAsync(message, "UpdatedTempPassword", model);
|
|
|
|
|
|
message.Category = "UpdatedTempPassword";
|
|
|
|
|
|
await _mailDeliveryService.SendEmailAsync(message);
|
2022-08-29 16:06:55 -04:00
|
|
|
|
}
|
Families for Enterprise (#1714)
* Create common test infrastructure project
* Add helpers to further type PlanTypes
* Enable testing of ASP.net MVC controllers
Controller properties have all kinds of validations in the background.
In general, we don't user properties on our Controllers, so the easiest
way to allow for Autofixture-based testing of our Controllers is to just
omit setting all properties on them.
* Workaround for broken MemberAutoDataAttribute
https://github.com/AutoFixture/AutoFixture/pull/1164 shows that only
the first test case is pulled for this attribute.
This is a workaround that populates the provided parameters, left to
right, using AutoFixture to populate any remaining.
* WIP: Organization sponsorship flow
* Add Attribute to use the Bit Autodata dependency chain
BitAutoDataAttribute is used to mark a Theory as autopopulating
parameters.
Extract common attribute methods to to a helper class. Cannot
inherit a common base, since both require inheriting from different
Xunit base classes to work.
* WIP: scaffolding for families for enterprise sponsorship flow
* Fix broken tests
* Create sponsorship offer (#1688)
* Initial db work (#1687)
* Add organization sponsorship databases to all providers
* Generalize create and update for database, specialize in code
* Add PlanSponsorshipType to db model
* Write valid json for test entries
* Initial scaffolding of emails (#1686)
* Initial scaffolding of emails
* Work on adding models for FamilyForEnterprise emails
* Switch verbage
* Put preliminary copy in emails
* Skip test
* Families for enterprise/stripe integrations (#1699)
* Add PlanSponsorshipType to static store
* Add sponsorship type to token and creates sponsorship
* PascalCase properties
* Require sponsorship for remove
* Create subscription sponsorship helper class
* Handle Sponsored subscription changes
* Add sponsorship id to subscription metadata
* Make sponsoring references nullable
This state indicates that a sponsorship has lapsed, but was not able to
be reverted for billing reasons
* WIP: Validate and remove subscriptions
* Update sponsorships on organization and org user delete
* Add friendly name to organization sponsorship
* Add sponsorship available boolean to orgDetails
* Add sponsorship service to DI
* Use userId to find org users
* Send f4e offer email
* Simplify names of f4e mail messages
* Fix Stripe org default tax rates
* Universal sponsorship redeem api
* Populate user in current context
* Add product type to organization details
* Use upgrade path to change sponsorship
Sponsorships need to be annual to match the GB add-on charge rate
* Use organization and auth to find organization sponsorship
* Add resend sponsorship offer api endpoint
* Fix double email send
* Fix sponsorship upgrade options
* Add is sponsored item to subscription response
* Add sponsorship validation to upcoming invoice webhook
* Add sponsorship validation to upcoming invoice webhook
* Fix organization delete sponsorship hooks
* Test org sponsorship service
* Fix sproc
* Create common test infrastructure project
* Add helpers to further type PlanTypes
* Enable testing of ASP.net MVC controllers
Controller properties have all kinds of validations in the background.
In general, we don't user properties on our Controllers, so the easiest
way to allow for Autofixture-based testing of our Controllers is to just
omit setting all properties on them.
* Workaround for broken MemberAutoDataAttribute
https://github.com/AutoFixture/AutoFixture/pull/1164 shows that only
the first test case is pulled for this attribute.
This is a workaround that populates the provided parameters, left to
right, using AutoFixture to populate any remaining.
* WIP: Organization sponsorship flow
* Add Attribute to use the Bit Autodata dependency chain
BitAutoDataAttribute is used to mark a Theory as autopopulating
parameters.
Extract common attribute methods to to a helper class. Cannot
inherit a common base, since both require inheriting from different
Xunit base classes to work.
* WIP: scaffolding for families for enterprise sponsorship flow
* Fix broken tests
* Create sponsorship offer (#1688)
* Initial db work (#1687)
* Add organization sponsorship databases to all providers
* Generalize create and update for database, specialize in code
* Add PlanSponsorshipType to db model
* Write valid json for test entries
* Initial scaffolding of emails (#1686)
* Initial scaffolding of emails
* Work on adding models for FamilyForEnterprise emails
* Switch verbage
* Put preliminary copy in emails
* Skip test
* Families for enterprise/stripe integrations (#1699)
* Add PlanSponsorshipType to static store
* Add sponsorship type to token and creates sponsorship
* PascalCase properties
* Require sponsorship for remove
* Create subscription sponsorship helper class
* Handle Sponsored subscription changes
* Add sponsorship id to subscription metadata
* Make sponsoring references nullable
This state indicates that a sponsorship has lapsed, but was not able to
be reverted for billing reasons
* WIP: Validate and remove subscriptions
* Update sponsorships on organization and org user delete
* Add friendly name to organization sponsorship
* Add sponsorship available boolean to orgDetails
* Add sponsorship service to DI
* Use userId to find org users
* Send f4e offer email
* Simplify names of f4e mail messages
* Fix Stripe org default tax rates
* Universal sponsorship redeem api
* Populate user in current context
* Add product type to organization details
* Use upgrade path to change sponsorship
Sponsorships need to be annual to match the GB add-on charge rate
* Use organization and auth to find organization sponsorship
* Add resend sponsorship offer api endpoint
* Fix double email send
* Fix sponsorship upgrade options
* Add is sponsored item to subscription response
* Add sponsorship validation to upcoming invoice webhook
* Add sponsorship validation to upcoming invoice webhook
* Fix organization delete sponsorship hooks
* Test org sponsorship service
* Fix sproc
* Fix build error
* Update emails
* Fix tests
* Skip local test
* Add newline
* Fix stripe subscription update
* Finish emails
* Skip test
* Fix unit tests
* Remove unused variable
* Fix unit tests
* Switch to handlebars ifs
* Remove ending email
* Remove reconfirmation template
* Switch naming convention
* Switch naming convention
* Fix migration
* Update copy and links
* Switch to using Guid in the method
* Remove unneeded css styles
* Add sql files to Sql.sqlproj
* Removed old comments
* Made name more verbose
* Fix SQL error
* Move unit tests to service
* Fix sp
* Revert "Move unit tests to service"
This reverts commit 1185bf3ec8ca36ccd75717ed2463adf8885159a6.
* Do repository validation in service layer
* Fix tests
* Fix merge conflicts and remove TODO
* Remove unneeded models
* Fix spacing and formatting
* Switch Org -> Organization
* Remove single use variables
* Switch method name
* Fix Controller
* Switch to obfuscating email
* Fix unit tests
Co-authored-by: Justin Baur <admin@justinbaur.com>
2021-11-19 16:25:06 -06:00
|
|
|
|
|
|
|
|
|
|
public async Task SendFamiliesForEnterpriseOfferEmailAsync(string sponsorOrgName, string email, bool existingAccount, string token) =>
|
|
|
|
|
|
await BulkSendFamiliesForEnterpriseOfferEmailAsync(sponsorOrgName, new[] { (email, existingAccount, token) });
|
|
|
|
|
|
|
2022-05-10 17:12:09 -04:00
|
|
|
|
public async Task BulkSendFamiliesForEnterpriseOfferEmailAsync(string sponsorOrgName, IEnumerable<(string Email, bool ExistingAccount, string Token)> invites)
|
2022-08-29 16:06:55 -04:00
|
|
|
|
{
|
2022-05-10 17:12:09 -04:00
|
|
|
|
MailQueueMessage CreateMessage((string Email, bool ExistingAccount, string Token) invite)
|
Families for Enterprise (#1714)
* Create common test infrastructure project
* Add helpers to further type PlanTypes
* Enable testing of ASP.net MVC controllers
Controller properties have all kinds of validations in the background.
In general, we don't user properties on our Controllers, so the easiest
way to allow for Autofixture-based testing of our Controllers is to just
omit setting all properties on them.
* Workaround for broken MemberAutoDataAttribute
https://github.com/AutoFixture/AutoFixture/pull/1164 shows that only
the first test case is pulled for this attribute.
This is a workaround that populates the provided parameters, left to
right, using AutoFixture to populate any remaining.
* WIP: Organization sponsorship flow
* Add Attribute to use the Bit Autodata dependency chain
BitAutoDataAttribute is used to mark a Theory as autopopulating
parameters.
Extract common attribute methods to to a helper class. Cannot
inherit a common base, since both require inheriting from different
Xunit base classes to work.
* WIP: scaffolding for families for enterprise sponsorship flow
* Fix broken tests
* Create sponsorship offer (#1688)
* Initial db work (#1687)
* Add organization sponsorship databases to all providers
* Generalize create and update for database, specialize in code
* Add PlanSponsorshipType to db model
* Write valid json for test entries
* Initial scaffolding of emails (#1686)
* Initial scaffolding of emails
* Work on adding models for FamilyForEnterprise emails
* Switch verbage
* Put preliminary copy in emails
* Skip test
* Families for enterprise/stripe integrations (#1699)
* Add PlanSponsorshipType to static store
* Add sponsorship type to token and creates sponsorship
* PascalCase properties
* Require sponsorship for remove
* Create subscription sponsorship helper class
* Handle Sponsored subscription changes
* Add sponsorship id to subscription metadata
* Make sponsoring references nullable
This state indicates that a sponsorship has lapsed, but was not able to
be reverted for billing reasons
* WIP: Validate and remove subscriptions
* Update sponsorships on organization and org user delete
* Add friendly name to organization sponsorship
* Add sponsorship available boolean to orgDetails
* Add sponsorship service to DI
* Use userId to find org users
* Send f4e offer email
* Simplify names of f4e mail messages
* Fix Stripe org default tax rates
* Universal sponsorship redeem api
* Populate user in current context
* Add product type to organization details
* Use upgrade path to change sponsorship
Sponsorships need to be annual to match the GB add-on charge rate
* Use organization and auth to find organization sponsorship
* Add resend sponsorship offer api endpoint
* Fix double email send
* Fix sponsorship upgrade options
* Add is sponsored item to subscription response
* Add sponsorship validation to upcoming invoice webhook
* Add sponsorship validation to upcoming invoice webhook
* Fix organization delete sponsorship hooks
* Test org sponsorship service
* Fix sproc
* Create common test infrastructure project
* Add helpers to further type PlanTypes
* Enable testing of ASP.net MVC controllers
Controller properties have all kinds of validations in the background.
In general, we don't user properties on our Controllers, so the easiest
way to allow for Autofixture-based testing of our Controllers is to just
omit setting all properties on them.
* Workaround for broken MemberAutoDataAttribute
https://github.com/AutoFixture/AutoFixture/pull/1164 shows that only
the first test case is pulled for this attribute.
This is a workaround that populates the provided parameters, left to
right, using AutoFixture to populate any remaining.
* WIP: Organization sponsorship flow
* Add Attribute to use the Bit Autodata dependency chain
BitAutoDataAttribute is used to mark a Theory as autopopulating
parameters.
Extract common attribute methods to to a helper class. Cannot
inherit a common base, since both require inheriting from different
Xunit base classes to work.
* WIP: scaffolding for families for enterprise sponsorship flow
* Fix broken tests
* Create sponsorship offer (#1688)
* Initial db work (#1687)
* Add organization sponsorship databases to all providers
* Generalize create and update for database, specialize in code
* Add PlanSponsorshipType to db model
* Write valid json for test entries
* Initial scaffolding of emails (#1686)
* Initial scaffolding of emails
* Work on adding models for FamilyForEnterprise emails
* Switch verbage
* Put preliminary copy in emails
* Skip test
* Families for enterprise/stripe integrations (#1699)
* Add PlanSponsorshipType to static store
* Add sponsorship type to token and creates sponsorship
* PascalCase properties
* Require sponsorship for remove
* Create subscription sponsorship helper class
* Handle Sponsored subscription changes
* Add sponsorship id to subscription metadata
* Make sponsoring references nullable
This state indicates that a sponsorship has lapsed, but was not able to
be reverted for billing reasons
* WIP: Validate and remove subscriptions
* Update sponsorships on organization and org user delete
* Add friendly name to organization sponsorship
* Add sponsorship available boolean to orgDetails
* Add sponsorship service to DI
* Use userId to find org users
* Send f4e offer email
* Simplify names of f4e mail messages
* Fix Stripe org default tax rates
* Universal sponsorship redeem api
* Populate user in current context
* Add product type to organization details
* Use upgrade path to change sponsorship
Sponsorships need to be annual to match the GB add-on charge rate
* Use organization and auth to find organization sponsorship
* Add resend sponsorship offer api endpoint
* Fix double email send
* Fix sponsorship upgrade options
* Add is sponsored item to subscription response
* Add sponsorship validation to upcoming invoice webhook
* Add sponsorship validation to upcoming invoice webhook
* Fix organization delete sponsorship hooks
* Test org sponsorship service
* Fix sproc
* Fix build error
* Update emails
* Fix tests
* Skip local test
* Add newline
* Fix stripe subscription update
* Finish emails
* Skip test
* Fix unit tests
* Remove unused variable
* Fix unit tests
* Switch to handlebars ifs
* Remove ending email
* Remove reconfirmation template
* Switch naming convention
* Switch naming convention
* Fix migration
* Update copy and links
* Switch to using Guid in the method
* Remove unneeded css styles
* Add sql files to Sql.sqlproj
* Removed old comments
* Made name more verbose
* Fix SQL error
* Move unit tests to service
* Fix sp
* Revert "Move unit tests to service"
This reverts commit 1185bf3ec8ca36ccd75717ed2463adf8885159a6.
* Do repository validation in service layer
* Fix tests
* Fix merge conflicts and remove TODO
* Remove unneeded models
* Fix spacing and formatting
* Switch Org -> Organization
* Remove single use variables
* Switch method name
* Fix Controller
* Switch to obfuscating email
* Fix unit tests
Co-authored-by: Justin Baur <admin@justinbaur.com>
2021-11-19 16:25:06 -06:00
|
|
|
|
{
|
2022-05-10 17:12:09 -04:00
|
|
|
|
var message = CreateDefaultMessage("Accept Your Free Families Subscription", invite.Email);
|
|
|
|
|
|
message.Category = "FamiliesForEnterpriseOffer";
|
|
|
|
|
|
var model = new FamiliesForEnterpriseOfferViewModel
|
2022-08-29 16:06:55 -04:00
|
|
|
|
{
|
Families for Enterprise (#1714)
* Create common test infrastructure project
* Add helpers to further type PlanTypes
* Enable testing of ASP.net MVC controllers
Controller properties have all kinds of validations in the background.
In general, we don't user properties on our Controllers, so the easiest
way to allow for Autofixture-based testing of our Controllers is to just
omit setting all properties on them.
* Workaround for broken MemberAutoDataAttribute
https://github.com/AutoFixture/AutoFixture/pull/1164 shows that only
the first test case is pulled for this attribute.
This is a workaround that populates the provided parameters, left to
right, using AutoFixture to populate any remaining.
* WIP: Organization sponsorship flow
* Add Attribute to use the Bit Autodata dependency chain
BitAutoDataAttribute is used to mark a Theory as autopopulating
parameters.
Extract common attribute methods to to a helper class. Cannot
inherit a common base, since both require inheriting from different
Xunit base classes to work.
* WIP: scaffolding for families for enterprise sponsorship flow
* Fix broken tests
* Create sponsorship offer (#1688)
* Initial db work (#1687)
* Add organization sponsorship databases to all providers
* Generalize create and update for database, specialize in code
* Add PlanSponsorshipType to db model
* Write valid json for test entries
* Initial scaffolding of emails (#1686)
* Initial scaffolding of emails
* Work on adding models for FamilyForEnterprise emails
* Switch verbage
* Put preliminary copy in emails
* Skip test
* Families for enterprise/stripe integrations (#1699)
* Add PlanSponsorshipType to static store
* Add sponsorship type to token and creates sponsorship
* PascalCase properties
* Require sponsorship for remove
* Create subscription sponsorship helper class
* Handle Sponsored subscription changes
* Add sponsorship id to subscription metadata
* Make sponsoring references nullable
This state indicates that a sponsorship has lapsed, but was not able to
be reverted for billing reasons
* WIP: Validate and remove subscriptions
* Update sponsorships on organization and org user delete
* Add friendly name to organization sponsorship
* Add sponsorship available boolean to orgDetails
* Add sponsorship service to DI
* Use userId to find org users
* Send f4e offer email
* Simplify names of f4e mail messages
* Fix Stripe org default tax rates
* Universal sponsorship redeem api
* Populate user in current context
* Add product type to organization details
* Use upgrade path to change sponsorship
Sponsorships need to be annual to match the GB add-on charge rate
* Use organization and auth to find organization sponsorship
* Add resend sponsorship offer api endpoint
* Fix double email send
* Fix sponsorship upgrade options
* Add is sponsored item to subscription response
* Add sponsorship validation to upcoming invoice webhook
* Add sponsorship validation to upcoming invoice webhook
* Fix organization delete sponsorship hooks
* Test org sponsorship service
* Fix sproc
* Create common test infrastructure project
* Add helpers to further type PlanTypes
* Enable testing of ASP.net MVC controllers
Controller properties have all kinds of validations in the background.
In general, we don't user properties on our Controllers, so the easiest
way to allow for Autofixture-based testing of our Controllers is to just
omit setting all properties on them.
* Workaround for broken MemberAutoDataAttribute
https://github.com/AutoFixture/AutoFixture/pull/1164 shows that only
the first test case is pulled for this attribute.
This is a workaround that populates the provided parameters, left to
right, using AutoFixture to populate any remaining.
* WIP: Organization sponsorship flow
* Add Attribute to use the Bit Autodata dependency chain
BitAutoDataAttribute is used to mark a Theory as autopopulating
parameters.
Extract common attribute methods to to a helper class. Cannot
inherit a common base, since both require inheriting from different
Xunit base classes to work.
* WIP: scaffolding for families for enterprise sponsorship flow
* Fix broken tests
* Create sponsorship offer (#1688)
* Initial db work (#1687)
* Add organization sponsorship databases to all providers
* Generalize create and update for database, specialize in code
* Add PlanSponsorshipType to db model
* Write valid json for test entries
* Initial scaffolding of emails (#1686)
* Initial scaffolding of emails
* Work on adding models for FamilyForEnterprise emails
* Switch verbage
* Put preliminary copy in emails
* Skip test
* Families for enterprise/stripe integrations (#1699)
* Add PlanSponsorshipType to static store
* Add sponsorship type to token and creates sponsorship
* PascalCase properties
* Require sponsorship for remove
* Create subscription sponsorship helper class
* Handle Sponsored subscription changes
* Add sponsorship id to subscription metadata
* Make sponsoring references nullable
This state indicates that a sponsorship has lapsed, but was not able to
be reverted for billing reasons
* WIP: Validate and remove subscriptions
* Update sponsorships on organization and org user delete
* Add friendly name to organization sponsorship
* Add sponsorship available boolean to orgDetails
* Add sponsorship service to DI
* Use userId to find org users
* Send f4e offer email
* Simplify names of f4e mail messages
* Fix Stripe org default tax rates
* Universal sponsorship redeem api
* Populate user in current context
* Add product type to organization details
* Use upgrade path to change sponsorship
Sponsorships need to be annual to match the GB add-on charge rate
* Use organization and auth to find organization sponsorship
* Add resend sponsorship offer api endpoint
* Fix double email send
* Fix sponsorship upgrade options
* Add is sponsored item to subscription response
* Add sponsorship validation to upcoming invoice webhook
* Add sponsorship validation to upcoming invoice webhook
* Fix organization delete sponsorship hooks
* Test org sponsorship service
* Fix sproc
* Fix build error
* Update emails
* Fix tests
* Skip local test
* Add newline
* Fix stripe subscription update
* Finish emails
* Skip test
* Fix unit tests
* Remove unused variable
* Fix unit tests
* Switch to handlebars ifs
* Remove ending email
* Remove reconfirmation template
* Switch naming convention
* Switch naming convention
* Fix migration
* Update copy and links
* Switch to using Guid in the method
* Remove unneeded css styles
* Add sql files to Sql.sqlproj
* Removed old comments
* Made name more verbose
* Fix SQL error
* Move unit tests to service
* Fix sp
* Revert "Move unit tests to service"
This reverts commit 1185bf3ec8ca36ccd75717ed2463adf8885159a6.
* Do repository validation in service layer
* Fix tests
* Fix merge conflicts and remove TODO
* Remove unneeded models
* Fix spacing and formatting
* Switch Org -> Organization
* Remove single use variables
* Switch method name
* Fix Controller
* Switch to obfuscating email
* Fix unit tests
Co-authored-by: Justin Baur <admin@justinbaur.com>
2021-11-19 16:25:06 -06:00
|
|
|
|
SponsorOrgName = sponsorOrgName,
|
|
|
|
|
|
SponsoredEmail = WebUtility.UrlEncode(invite.Email),
|
|
|
|
|
|
ExistingAccount = invite.ExistingAccount,
|
|
|
|
|
|
WebVaultUrl = _globalSettings.BaseServiceUri.VaultWithHash,
|
2022-03-02 15:45:00 -06:00
|
|
|
|
SiteName = _globalSettings.SiteName,
|
Families for Enterprise (#1714)
* Create common test infrastructure project
* Add helpers to further type PlanTypes
* Enable testing of ASP.net MVC controllers
Controller properties have all kinds of validations in the background.
In general, we don't user properties on our Controllers, so the easiest
way to allow for Autofixture-based testing of our Controllers is to just
omit setting all properties on them.
* Workaround for broken MemberAutoDataAttribute
https://github.com/AutoFixture/AutoFixture/pull/1164 shows that only
the first test case is pulled for this attribute.
This is a workaround that populates the provided parameters, left to
right, using AutoFixture to populate any remaining.
* WIP: Organization sponsorship flow
* Add Attribute to use the Bit Autodata dependency chain
BitAutoDataAttribute is used to mark a Theory as autopopulating
parameters.
Extract common attribute methods to to a helper class. Cannot
inherit a common base, since both require inheriting from different
Xunit base classes to work.
* WIP: scaffolding for families for enterprise sponsorship flow
* Fix broken tests
* Create sponsorship offer (#1688)
* Initial db work (#1687)
* Add organization sponsorship databases to all providers
* Generalize create and update for database, specialize in code
* Add PlanSponsorshipType to db model
* Write valid json for test entries
* Initial scaffolding of emails (#1686)
* Initial scaffolding of emails
* Work on adding models for FamilyForEnterprise emails
* Switch verbage
* Put preliminary copy in emails
* Skip test
* Families for enterprise/stripe integrations (#1699)
* Add PlanSponsorshipType to static store
* Add sponsorship type to token and creates sponsorship
* PascalCase properties
* Require sponsorship for remove
* Create subscription sponsorship helper class
* Handle Sponsored subscription changes
* Add sponsorship id to subscription metadata
* Make sponsoring references nullable
This state indicates that a sponsorship has lapsed, but was not able to
be reverted for billing reasons
* WIP: Validate and remove subscriptions
* Update sponsorships on organization and org user delete
* Add friendly name to organization sponsorship
* Add sponsorship available boolean to orgDetails
* Add sponsorship service to DI
* Use userId to find org users
* Send f4e offer email
* Simplify names of f4e mail messages
* Fix Stripe org default tax rates
* Universal sponsorship redeem api
* Populate user in current context
* Add product type to organization details
* Use upgrade path to change sponsorship
Sponsorships need to be annual to match the GB add-on charge rate
* Use organization and auth to find organization sponsorship
* Add resend sponsorship offer api endpoint
* Fix double email send
* Fix sponsorship upgrade options
* Add is sponsored item to subscription response
* Add sponsorship validation to upcoming invoice webhook
* Add sponsorship validation to upcoming invoice webhook
* Fix organization delete sponsorship hooks
* Test org sponsorship service
* Fix sproc
* Create common test infrastructure project
* Add helpers to further type PlanTypes
* Enable testing of ASP.net MVC controllers
Controller properties have all kinds of validations in the background.
In general, we don't user properties on our Controllers, so the easiest
way to allow for Autofixture-based testing of our Controllers is to just
omit setting all properties on them.
* Workaround for broken MemberAutoDataAttribute
https://github.com/AutoFixture/AutoFixture/pull/1164 shows that only
the first test case is pulled for this attribute.
This is a workaround that populates the provided parameters, left to
right, using AutoFixture to populate any remaining.
* WIP: Organization sponsorship flow
* Add Attribute to use the Bit Autodata dependency chain
BitAutoDataAttribute is used to mark a Theory as autopopulating
parameters.
Extract common attribute methods to to a helper class. Cannot
inherit a common base, since both require inheriting from different
Xunit base classes to work.
* WIP: scaffolding for families for enterprise sponsorship flow
* Fix broken tests
* Create sponsorship offer (#1688)
* Initial db work (#1687)
* Add organization sponsorship databases to all providers
* Generalize create and update for database, specialize in code
* Add PlanSponsorshipType to db model
* Write valid json for test entries
* Initial scaffolding of emails (#1686)
* Initial scaffolding of emails
* Work on adding models for FamilyForEnterprise emails
* Switch verbage
* Put preliminary copy in emails
* Skip test
* Families for enterprise/stripe integrations (#1699)
* Add PlanSponsorshipType to static store
* Add sponsorship type to token and creates sponsorship
* PascalCase properties
* Require sponsorship for remove
* Create subscription sponsorship helper class
* Handle Sponsored subscription changes
* Add sponsorship id to subscription metadata
* Make sponsoring references nullable
This state indicates that a sponsorship has lapsed, but was not able to
be reverted for billing reasons
* WIP: Validate and remove subscriptions
* Update sponsorships on organization and org user delete
* Add friendly name to organization sponsorship
* Add sponsorship available boolean to orgDetails
* Add sponsorship service to DI
* Use userId to find org users
* Send f4e offer email
* Simplify names of f4e mail messages
* Fix Stripe org default tax rates
* Universal sponsorship redeem api
* Populate user in current context
* Add product type to organization details
* Use upgrade path to change sponsorship
Sponsorships need to be annual to match the GB add-on charge rate
* Use organization and auth to find organization sponsorship
* Add resend sponsorship offer api endpoint
* Fix double email send
* Fix sponsorship upgrade options
* Add is sponsored item to subscription response
* Add sponsorship validation to upcoming invoice webhook
* Add sponsorship validation to upcoming invoice webhook
* Fix organization delete sponsorship hooks
* Test org sponsorship service
* Fix sproc
* Fix build error
* Update emails
* Fix tests
* Skip local test
* Add newline
* Fix stripe subscription update
* Finish emails
* Skip test
* Fix unit tests
* Remove unused variable
* Fix unit tests
* Switch to handlebars ifs
* Remove ending email
* Remove reconfirmation template
* Switch naming convention
* Switch naming convention
* Fix migration
* Update copy and links
* Switch to using Guid in the method
* Remove unneeded css styles
* Add sql files to Sql.sqlproj
* Removed old comments
* Made name more verbose
* Fix SQL error
* Move unit tests to service
* Fix sp
* Revert "Move unit tests to service"
This reverts commit 1185bf3ec8ca36ccd75717ed2463adf8885159a6.
* Do repository validation in service layer
* Fix tests
* Fix merge conflicts and remove TODO
* Remove unneeded models
* Fix spacing and formatting
* Switch Org -> Organization
* Remove single use variables
* Switch method name
* Fix Controller
* Switch to obfuscating email
* Fix unit tests
Co-authored-by: Justin Baur <admin@justinbaur.com>
2021-11-19 16:25:06 -06:00
|
|
|
|
SponsorshipToken = invite.Token,
|
|
|
|
|
|
};
|
|
|
|
|
|
var templateName = invite.ExistingAccount ?
|
|
|
|
|
|
"FamiliesForEnterprise.FamiliesForEnterpriseOfferExistingAccount" :
|
|
|
|
|
|
"FamiliesForEnterprise.FamiliesForEnterpriseOfferNewAccount";
|
2021-12-16 15:35:09 +01:00
|
|
|
|
|
2021-11-09 16:37:32 +01:00
|
|
|
|
return new MailQueueMessage(message, templateName, model);
|
|
|
|
|
|
}
|
2022-05-10 17:12:09 -04:00
|
|
|
|
var messageModels = invites.Select(invite => CreateMessage(invite));
|
|
|
|
|
|
await EnqueueMailAsync(messageModels);
|
2022-08-29 16:06:55 -04:00
|
|
|
|
}
|
2022-03-02 15:45:00 -06:00
|
|
|
|
|
|
|
|
|
|
public async Task SendFamiliesForEnterpriseRedeemedEmailsAsync(string familyUserEmail, string sponsorEmail)
|
|
|
|
|
|
{
|
|
|
|
|
|
// Email family user
|
|
|
|
|
|
await SendFamiliesForEnterpriseInviteRedeemedToFamilyUserEmailAsync(familyUserEmail);
|
|
|
|
|
|
|
|
|
|
|
|
// Email enterprise org user
|
|
|
|
|
|
await SendFamiliesForEnterpriseInviteRedeemedToEnterpriseUserEmailAsync(sponsorEmail);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private async Task SendFamiliesForEnterpriseInviteRedeemedToFamilyUserEmailAsync(string email)
|
|
|
|
|
|
{
|
|
|
|
|
|
var message = CreateDefaultMessage("Success! Families Subscription Accepted", email);
|
|
|
|
|
|
await AddMessageContentAsync(message, "FamiliesForEnterprise.FamiliesForEnterpriseRedeemedToFamilyUser", new BaseMailModel());
|
|
|
|
|
|
message.Category = "FamilyForEnterpriseRedeemedToFamilyUser";
|
|
|
|
|
|
await _mailDeliveryService.SendEmailAsync(message);
|
2022-08-29 14:53:16 -04:00
|
|
|
|
}
|
2022-03-02 15:45:00 -06:00
|
|
|
|
|
2018-08-03 23:04:47 -04:00
|
|
|
|
private async Task SendFamiliesForEnterpriseInviteRedeemedToEnterpriseUserEmailAsync(string email)
|
2022-08-29 14:53:16 -04:00
|
|
|
|
{
|
Families for Enterprise (#1714)
* Create common test infrastructure project
* Add helpers to further type PlanTypes
* Enable testing of ASP.net MVC controllers
Controller properties have all kinds of validations in the background.
In general, we don't user properties on our Controllers, so the easiest
way to allow for Autofixture-based testing of our Controllers is to just
omit setting all properties on them.
* Workaround for broken MemberAutoDataAttribute
https://github.com/AutoFixture/AutoFixture/pull/1164 shows that only
the first test case is pulled for this attribute.
This is a workaround that populates the provided parameters, left to
right, using AutoFixture to populate any remaining.
* WIP: Organization sponsorship flow
* Add Attribute to use the Bit Autodata dependency chain
BitAutoDataAttribute is used to mark a Theory as autopopulating
parameters.
Extract common attribute methods to to a helper class. Cannot
inherit a common base, since both require inheriting from different
Xunit base classes to work.
* WIP: scaffolding for families for enterprise sponsorship flow
* Fix broken tests
* Create sponsorship offer (#1688)
* Initial db work (#1687)
* Add organization sponsorship databases to all providers
* Generalize create and update for database, specialize in code
* Add PlanSponsorshipType to db model
* Write valid json for test entries
* Initial scaffolding of emails (#1686)
* Initial scaffolding of emails
* Work on adding models for FamilyForEnterprise emails
* Switch verbage
* Put preliminary copy in emails
* Skip test
* Families for enterprise/stripe integrations (#1699)
* Add PlanSponsorshipType to static store
* Add sponsorship type to token and creates sponsorship
* PascalCase properties
* Require sponsorship for remove
* Create subscription sponsorship helper class
* Handle Sponsored subscription changes
* Add sponsorship id to subscription metadata
* Make sponsoring references nullable
This state indicates that a sponsorship has lapsed, but was not able to
be reverted for billing reasons
* WIP: Validate and remove subscriptions
* Update sponsorships on organization and org user delete
* Add friendly name to organization sponsorship
* Add sponsorship available boolean to orgDetails
* Add sponsorship service to DI
* Use userId to find org users
* Send f4e offer email
* Simplify names of f4e mail messages
* Fix Stripe org default tax rates
* Universal sponsorship redeem api
* Populate user in current context
* Add product type to organization details
* Use upgrade path to change sponsorship
Sponsorships need to be annual to match the GB add-on charge rate
* Use organization and auth to find organization sponsorship
* Add resend sponsorship offer api endpoint
* Fix double email send
* Fix sponsorship upgrade options
* Add is sponsored item to subscription response
* Add sponsorship validation to upcoming invoice webhook
* Add sponsorship validation to upcoming invoice webhook
* Fix organization delete sponsorship hooks
* Test org sponsorship service
* Fix sproc
* Create common test infrastructure project
* Add helpers to further type PlanTypes
* Enable testing of ASP.net MVC controllers
Controller properties have all kinds of validations in the background.
In general, we don't user properties on our Controllers, so the easiest
way to allow for Autofixture-based testing of our Controllers is to just
omit setting all properties on them.
* Workaround for broken MemberAutoDataAttribute
https://github.com/AutoFixture/AutoFixture/pull/1164 shows that only
the first test case is pulled for this attribute.
This is a workaround that populates the provided parameters, left to
right, using AutoFixture to populate any remaining.
* WIP: Organization sponsorship flow
* Add Attribute to use the Bit Autodata dependency chain
BitAutoDataAttribute is used to mark a Theory as autopopulating
parameters.
Extract common attribute methods to to a helper class. Cannot
inherit a common base, since both require inheriting from different
Xunit base classes to work.
* WIP: scaffolding for families for enterprise sponsorship flow
* Fix broken tests
* Create sponsorship offer (#1688)
* Initial db work (#1687)
* Add organization sponsorship databases to all providers
* Generalize create and update for database, specialize in code
* Add PlanSponsorshipType to db model
* Write valid json for test entries
* Initial scaffolding of emails (#1686)
* Initial scaffolding of emails
* Work on adding models for FamilyForEnterprise emails
* Switch verbage
* Put preliminary copy in emails
* Skip test
* Families for enterprise/stripe integrations (#1699)
* Add PlanSponsorshipType to static store
* Add sponsorship type to token and creates sponsorship
* PascalCase properties
* Require sponsorship for remove
* Create subscription sponsorship helper class
* Handle Sponsored subscription changes
* Add sponsorship id to subscription metadata
* Make sponsoring references nullable
This state indicates that a sponsorship has lapsed, but was not able to
be reverted for billing reasons
* WIP: Validate and remove subscriptions
* Update sponsorships on organization and org user delete
* Add friendly name to organization sponsorship
* Add sponsorship available boolean to orgDetails
* Add sponsorship service to DI
* Use userId to find org users
* Send f4e offer email
* Simplify names of f4e mail messages
* Fix Stripe org default tax rates
* Universal sponsorship redeem api
* Populate user in current context
* Add product type to organization details
* Use upgrade path to change sponsorship
Sponsorships need to be annual to match the GB add-on charge rate
* Use organization and auth to find organization sponsorship
* Add resend sponsorship offer api endpoint
* Fix double email send
* Fix sponsorship upgrade options
* Add is sponsored item to subscription response
* Add sponsorship validation to upcoming invoice webhook
* Add sponsorship validation to upcoming invoice webhook
* Fix organization delete sponsorship hooks
* Test org sponsorship service
* Fix sproc
* Fix build error
* Update emails
* Fix tests
* Skip local test
* Add newline
* Fix stripe subscription update
* Finish emails
* Skip test
* Fix unit tests
* Remove unused variable
* Fix unit tests
* Switch to handlebars ifs
* Remove ending email
* Remove reconfirmation template
* Switch naming convention
* Switch naming convention
* Fix migration
* Update copy and links
* Switch to using Guid in the method
* Remove unneeded css styles
* Add sql files to Sql.sqlproj
* Removed old comments
* Made name more verbose
* Fix SQL error
* Move unit tests to service
* Fix sp
* Revert "Move unit tests to service"
This reverts commit 1185bf3ec8ca36ccd75717ed2463adf8885159a6.
* Do repository validation in service layer
* Fix tests
* Fix merge conflicts and remove TODO
* Remove unneeded models
* Fix spacing and formatting
* Switch Org -> Organization
* Remove single use variables
* Switch method name
* Fix Controller
* Switch to obfuscating email
* Fix unit tests
Co-authored-by: Justin Baur <admin@justinbaur.com>
2021-11-19 16:25:06 -06:00
|
|
|
|
var message = CreateDefaultMessage("Success! Families Subscription Accepted", email);
|
2022-03-02 15:45:00 -06:00
|
|
|
|
await AddMessageContentAsync(message, "FamiliesForEnterprise.FamiliesForEnterpriseRedeemedToEnterpriseUser", new BaseMailModel());
|
|
|
|
|
|
message.Category = "FamilyForEnterpriseRedeemedToEnterpriseUser";
|
|
|
|
|
|
await _mailDeliveryService.SendEmailAsync(message);
|
|
|
|
|
|
}
|
2022-06-23 10:44:41 -05:00
|
|
|
|
|
2022-05-10 17:12:09 -04:00
|
|
|
|
public async Task SendFamiliesForEnterpriseSponsorshipRevertingEmailAsync(string email, DateTime expirationDate)
|
2022-08-29 15:53:48 -04:00
|
|
|
|
{
|
2021-11-09 16:37:32 +01:00
|
|
|
|
var message = CreateDefaultMessage("Your Families Sponsorship was Removed", email);
|
2022-04-01 17:08:47 -03:00
|
|
|
|
var model = new FamiliesForEnterpriseSponsorshipRevertingViewModel
|
2022-08-29 15:53:48 -04:00
|
|
|
|
{
|
2019-12-23 15:26:39 -05:00
|
|
|
|
ExpirationDate = expirationDate,
|
2022-08-29 16:06:55 -04:00
|
|
|
|
};
|
2019-12-23 15:26:39 -05:00
|
|
|
|
await AddMessageContentAsync(message, "FamiliesForEnterprise.FamiliesForEnterpriseSponsorshipReverting", model);
|
2022-03-02 15:45:00 -06:00
|
|
|
|
message.Category = "FamiliesForEnterpriseSponsorshipReverting";
|
|
|
|
|
|
await _mailDeliveryService.SendEmailAsync(message);
|
2022-08-29 16:06:55 -04:00
|
|
|
|
}
|
2022-08-29 15:53:48 -04:00
|
|
|
|
|
2022-05-10 17:12:09 -04:00
|
|
|
|
public async Task SendOTPEmailAsync(string email, string token)
|
2022-08-29 16:06:55 -04:00
|
|
|
|
{
|
2021-11-09 16:37:32 +01:00
|
|
|
|
var message = CreateDefaultMessage("Your Bitwarden Verification Code", email);
|
Families for Enterprise (#1714)
* Create common test infrastructure project
* Add helpers to further type PlanTypes
* Enable testing of ASP.net MVC controllers
Controller properties have all kinds of validations in the background.
In general, we don't user properties on our Controllers, so the easiest
way to allow for Autofixture-based testing of our Controllers is to just
omit setting all properties on them.
* Workaround for broken MemberAutoDataAttribute
https://github.com/AutoFixture/AutoFixture/pull/1164 shows that only
the first test case is pulled for this attribute.
This is a workaround that populates the provided parameters, left to
right, using AutoFixture to populate any remaining.
* WIP: Organization sponsorship flow
* Add Attribute to use the Bit Autodata dependency chain
BitAutoDataAttribute is used to mark a Theory as autopopulating
parameters.
Extract common attribute methods to to a helper class. Cannot
inherit a common base, since both require inheriting from different
Xunit base classes to work.
* WIP: scaffolding for families for enterprise sponsorship flow
* Fix broken tests
* Create sponsorship offer (#1688)
* Initial db work (#1687)
* Add organization sponsorship databases to all providers
* Generalize create and update for database, specialize in code
* Add PlanSponsorshipType to db model
* Write valid json for test entries
* Initial scaffolding of emails (#1686)
* Initial scaffolding of emails
* Work on adding models for FamilyForEnterprise emails
* Switch verbage
* Put preliminary copy in emails
* Skip test
* Families for enterprise/stripe integrations (#1699)
* Add PlanSponsorshipType to static store
* Add sponsorship type to token and creates sponsorship
* PascalCase properties
* Require sponsorship for remove
* Create subscription sponsorship helper class
* Handle Sponsored subscription changes
* Add sponsorship id to subscription metadata
* Make sponsoring references nullable
This state indicates that a sponsorship has lapsed, but was not able to
be reverted for billing reasons
* WIP: Validate and remove subscriptions
* Update sponsorships on organization and org user delete
* Add friendly name to organization sponsorship
* Add sponsorship available boolean to orgDetails
* Add sponsorship service to DI
* Use userId to find org users
* Send f4e offer email
* Simplify names of f4e mail messages
* Fix Stripe org default tax rates
* Universal sponsorship redeem api
* Populate user in current context
* Add product type to organization details
* Use upgrade path to change sponsorship
Sponsorships need to be annual to match the GB add-on charge rate
* Use organization and auth to find organization sponsorship
* Add resend sponsorship offer api endpoint
* Fix double email send
* Fix sponsorship upgrade options
* Add is sponsored item to subscription response
* Add sponsorship validation to upcoming invoice webhook
* Add sponsorship validation to upcoming invoice webhook
* Fix organization delete sponsorship hooks
* Test org sponsorship service
* Fix sproc
* Create common test infrastructure project
* Add helpers to further type PlanTypes
* Enable testing of ASP.net MVC controllers
Controller properties have all kinds of validations in the background.
In general, we don't user properties on our Controllers, so the easiest
way to allow for Autofixture-based testing of our Controllers is to just
omit setting all properties on them.
* Workaround for broken MemberAutoDataAttribute
https://github.com/AutoFixture/AutoFixture/pull/1164 shows that only
the first test case is pulled for this attribute.
This is a workaround that populates the provided parameters, left to
right, using AutoFixture to populate any remaining.
* WIP: Organization sponsorship flow
* Add Attribute to use the Bit Autodata dependency chain
BitAutoDataAttribute is used to mark a Theory as autopopulating
parameters.
Extract common attribute methods to to a helper class. Cannot
inherit a common base, since both require inheriting from different
Xunit base classes to work.
* WIP: scaffolding for families for enterprise sponsorship flow
* Fix broken tests
* Create sponsorship offer (#1688)
* Initial db work (#1687)
* Add organization sponsorship databases to all providers
* Generalize create and update for database, specialize in code
* Add PlanSponsorshipType to db model
* Write valid json for test entries
* Initial scaffolding of emails (#1686)
* Initial scaffolding of emails
* Work on adding models for FamilyForEnterprise emails
* Switch verbage
* Put preliminary copy in emails
* Skip test
* Families for enterprise/stripe integrations (#1699)
* Add PlanSponsorshipType to static store
* Add sponsorship type to token and creates sponsorship
* PascalCase properties
* Require sponsorship for remove
* Create subscription sponsorship helper class
* Handle Sponsored subscription changes
* Add sponsorship id to subscription metadata
* Make sponsoring references nullable
This state indicates that a sponsorship has lapsed, but was not able to
be reverted for billing reasons
* WIP: Validate and remove subscriptions
* Update sponsorships on organization and org user delete
* Add friendly name to organization sponsorship
* Add sponsorship available boolean to orgDetails
* Add sponsorship service to DI
* Use userId to find org users
* Send f4e offer email
* Simplify names of f4e mail messages
* Fix Stripe org default tax rates
* Universal sponsorship redeem api
* Populate user in current context
* Add product type to organization details
* Use upgrade path to change sponsorship
Sponsorships need to be annual to match the GB add-on charge rate
* Use organization and auth to find organization sponsorship
* Add resend sponsorship offer api endpoint
* Fix double email send
* Fix sponsorship upgrade options
* Add is sponsored item to subscription response
* Add sponsorship validation to upcoming invoice webhook
* Add sponsorship validation to upcoming invoice webhook
* Fix organization delete sponsorship hooks
* Test org sponsorship service
* Fix sproc
* Fix build error
* Update emails
* Fix tests
* Skip local test
* Add newline
* Fix stripe subscription update
* Finish emails
* Skip test
* Fix unit tests
* Remove unused variable
* Fix unit tests
* Switch to handlebars ifs
* Remove ending email
* Remove reconfirmation template
* Switch naming convention
* Switch naming convention
* Fix migration
* Update copy and links
* Switch to using Guid in the method
* Remove unneeded css styles
* Add sql files to Sql.sqlproj
* Removed old comments
* Made name more verbose
* Fix SQL error
* Move unit tests to service
* Fix sp
* Revert "Move unit tests to service"
This reverts commit 1185bf3ec8ca36ccd75717ed2463adf8885159a6.
* Do repository validation in service layer
* Fix tests
* Fix merge conflicts and remove TODO
* Remove unneeded models
* Fix spacing and formatting
* Switch Org -> Organization
* Remove single use variables
* Switch method name
* Fix Controller
* Switch to obfuscating email
* Fix unit tests
Co-authored-by: Justin Baur <admin@justinbaur.com>
2021-11-19 16:25:06 -06:00
|
|
|
|
var model = new EmailTokenViewModel
|
2022-08-29 16:06:55 -04:00
|
|
|
|
{
|
2019-12-23 15:26:39 -05:00
|
|
|
|
Token = token,
|
|
|
|
|
|
WebVaultUrl = _globalSettings.BaseServiceUri.VaultWithHash,
|
2021-11-09 16:37:32 +01:00
|
|
|
|
SiteName = _globalSettings.SiteName,
|
2022-08-29 16:06:55 -04:00
|
|
|
|
};
|
2023-04-14 13:25:56 -04:00
|
|
|
|
await AddMessageContentAsync(message, "Auth.OTPEmail", model);
|
2021-11-09 16:37:32 +01:00
|
|
|
|
message.MetaData.Add("SendGridBypassListManagement", true);
|
|
|
|
|
|
message.Category = "OTP";
|
|
|
|
|
|
await _mailDeliveryService.SendEmailAsync(message);
|
2022-08-29 15:53:48 -04:00
|
|
|
|
}
|
|
|
|
|
|
|
2022-05-10 17:12:09 -04:00
|
|
|
|
public async Task SendFailedLoginAttemptsEmailAsync(string email, DateTime utcNow, string ip)
|
2022-08-29 15:53:48 -04:00
|
|
|
|
{
|
2021-11-09 16:37:32 +01:00
|
|
|
|
var message = CreateDefaultMessage("Failed login attempts detected", email);
|
2022-04-01 17:08:47 -03:00
|
|
|
|
var model = new FailedAuthAttemptsModel()
|
2022-08-29 15:53:48 -04:00
|
|
|
|
{
|
2019-12-23 15:26:39 -05:00
|
|
|
|
TheDate = utcNow.ToLongDateString(),
|
2022-03-02 15:45:00 -06:00
|
|
|
|
TheTime = utcNow.ToShortTimeString(),
|
[AC-1191] TDE admin approval email (#3044)
* feat: add new command for updating request and emailing user, refs AC-1191
* feat: inject service with organization service collection extensions, refs AC-1191
* feat: add function to send admin approval email to mail services (interface/noop/handlebars), refs AC-1191
* feat: add html/text mail templates and add view model for email data, refs AC-1191
* feat: update org auth request controller to use new command during auth request update, refs AC-1191
* fix: dotnet format, refs AC-1191
* refactor: update user not found error, FirstOrDefault for enum type display name, refs AC-1191
* refactor: update user not found to log error instead of throws, refs AC-1191
* fix: remove whitespace lint errors, refs AC-1191
* refactor: update hardcoded UTC timezone string, refs AC-1191
* refactor: add unit test for new command, refs AC-1191
* refactor: improve enum name fallback and identifier string creation, refs AC-1191
* refactor: add addtional unit tests, refs AC-1191
* refactor: update success test to use more generated params, refs AC-1191
* fix: dotnet format...again, refs AC-1191
* refactor: make UTC display a constant for handlebars mail service, refs AC-1191
* refactor: update displayTypeIdentifer to displayTypeAndIdentifier for clarity, refs AC-1191
2023-07-06 10:03:49 -05:00
|
|
|
|
TimeZone = _utcTimeZoneDisplay,
|
2022-03-02 15:45:00 -06:00
|
|
|
|
IpAddress = ip,
|
2022-05-10 17:12:09 -04:00
|
|
|
|
AffectedEmail = email
|
2022-08-29 16:06:55 -04:00
|
|
|
|
|
|
|
|
|
|
};
|
2023-04-14 13:25:56 -04:00
|
|
|
|
await AddMessageContentAsync(message, "Auth.FailedLoginAttempts", model);
|
Families for Enterprise (#1714)
* Create common test infrastructure project
* Add helpers to further type PlanTypes
* Enable testing of ASP.net MVC controllers
Controller properties have all kinds of validations in the background.
In general, we don't user properties on our Controllers, so the easiest
way to allow for Autofixture-based testing of our Controllers is to just
omit setting all properties on them.
* Workaround for broken MemberAutoDataAttribute
https://github.com/AutoFixture/AutoFixture/pull/1164 shows that only
the first test case is pulled for this attribute.
This is a workaround that populates the provided parameters, left to
right, using AutoFixture to populate any remaining.
* WIP: Organization sponsorship flow
* Add Attribute to use the Bit Autodata dependency chain
BitAutoDataAttribute is used to mark a Theory as autopopulating
parameters.
Extract common attribute methods to to a helper class. Cannot
inherit a common base, since both require inheriting from different
Xunit base classes to work.
* WIP: scaffolding for families for enterprise sponsorship flow
* Fix broken tests
* Create sponsorship offer (#1688)
* Initial db work (#1687)
* Add organization sponsorship databases to all providers
* Generalize create and update for database, specialize in code
* Add PlanSponsorshipType to db model
* Write valid json for test entries
* Initial scaffolding of emails (#1686)
* Initial scaffolding of emails
* Work on adding models for FamilyForEnterprise emails
* Switch verbage
* Put preliminary copy in emails
* Skip test
* Families for enterprise/stripe integrations (#1699)
* Add PlanSponsorshipType to static store
* Add sponsorship type to token and creates sponsorship
* PascalCase properties
* Require sponsorship for remove
* Create subscription sponsorship helper class
* Handle Sponsored subscription changes
* Add sponsorship id to subscription metadata
* Make sponsoring references nullable
This state indicates that a sponsorship has lapsed, but was not able to
be reverted for billing reasons
* WIP: Validate and remove subscriptions
* Update sponsorships on organization and org user delete
* Add friendly name to organization sponsorship
* Add sponsorship available boolean to orgDetails
* Add sponsorship service to DI
* Use userId to find org users
* Send f4e offer email
* Simplify names of f4e mail messages
* Fix Stripe org default tax rates
* Universal sponsorship redeem api
* Populate user in current context
* Add product type to organization details
* Use upgrade path to change sponsorship
Sponsorships need to be annual to match the GB add-on charge rate
* Use organization and auth to find organization sponsorship
* Add resend sponsorship offer api endpoint
* Fix double email send
* Fix sponsorship upgrade options
* Add is sponsored item to subscription response
* Add sponsorship validation to upcoming invoice webhook
* Add sponsorship validation to upcoming invoice webhook
* Fix organization delete sponsorship hooks
* Test org sponsorship service
* Fix sproc
* Create common test infrastructure project
* Add helpers to further type PlanTypes
* Enable testing of ASP.net MVC controllers
Controller properties have all kinds of validations in the background.
In general, we don't user properties on our Controllers, so the easiest
way to allow for Autofixture-based testing of our Controllers is to just
omit setting all properties on them.
* Workaround for broken MemberAutoDataAttribute
https://github.com/AutoFixture/AutoFixture/pull/1164 shows that only
the first test case is pulled for this attribute.
This is a workaround that populates the provided parameters, left to
right, using AutoFixture to populate any remaining.
* WIP: Organization sponsorship flow
* Add Attribute to use the Bit Autodata dependency chain
BitAutoDataAttribute is used to mark a Theory as autopopulating
parameters.
Extract common attribute methods to to a helper class. Cannot
inherit a common base, since both require inheriting from different
Xunit base classes to work.
* WIP: scaffolding for families for enterprise sponsorship flow
* Fix broken tests
* Create sponsorship offer (#1688)
* Initial db work (#1687)
* Add organization sponsorship databases to all providers
* Generalize create and update for database, specialize in code
* Add PlanSponsorshipType to db model
* Write valid json for test entries
* Initial scaffolding of emails (#1686)
* Initial scaffolding of emails
* Work on adding models for FamilyForEnterprise emails
* Switch verbage
* Put preliminary copy in emails
* Skip test
* Families for enterprise/stripe integrations (#1699)
* Add PlanSponsorshipType to static store
* Add sponsorship type to token and creates sponsorship
* PascalCase properties
* Require sponsorship for remove
* Create subscription sponsorship helper class
* Handle Sponsored subscription changes
* Add sponsorship id to subscription metadata
* Make sponsoring references nullable
This state indicates that a sponsorship has lapsed, but was not able to
be reverted for billing reasons
* WIP: Validate and remove subscriptions
* Update sponsorships on organization and org user delete
* Add friendly name to organization sponsorship
* Add sponsorship available boolean to orgDetails
* Add sponsorship service to DI
* Use userId to find org users
* Send f4e offer email
* Simplify names of f4e mail messages
* Fix Stripe org default tax rates
* Universal sponsorship redeem api
* Populate user in current context
* Add product type to organization details
* Use upgrade path to change sponsorship
Sponsorships need to be annual to match the GB add-on charge rate
* Use organization and auth to find organization sponsorship
* Add resend sponsorship offer api endpoint
* Fix double email send
* Fix sponsorship upgrade options
* Add is sponsored item to subscription response
* Add sponsorship validation to upcoming invoice webhook
* Add sponsorship validation to upcoming invoice webhook
* Fix organization delete sponsorship hooks
* Test org sponsorship service
* Fix sproc
* Fix build error
* Update emails
* Fix tests
* Skip local test
* Add newline
* Fix stripe subscription update
* Finish emails
* Skip test
* Fix unit tests
* Remove unused variable
* Fix unit tests
* Switch to handlebars ifs
* Remove ending email
* Remove reconfirmation template
* Switch naming convention
* Switch naming convention
* Fix migration
* Update copy and links
* Switch to using Guid in the method
* Remove unneeded css styles
* Add sql files to Sql.sqlproj
* Removed old comments
* Made name more verbose
* Fix SQL error
* Move unit tests to service
* Fix sp
* Revert "Move unit tests to service"
This reverts commit 1185bf3ec8ca36ccd75717ed2463adf8885159a6.
* Do repository validation in service layer
* Fix tests
* Fix merge conflicts and remove TODO
* Remove unneeded models
* Fix spacing and formatting
* Switch Org -> Organization
* Remove single use variables
* Switch method name
* Fix Controller
* Switch to obfuscating email
* Fix unit tests
Co-authored-by: Justin Baur <admin@justinbaur.com>
2021-11-19 16:25:06 -06:00
|
|
|
|
message.Category = "FailedLoginAttempts";
|
2021-11-09 16:37:32 +01:00
|
|
|
|
await _mailDeliveryService.SendEmailAsync(message);
|
2022-08-29 16:06:55 -04:00
|
|
|
|
}
|
2022-08-29 15:53:48 -04:00
|
|
|
|
|
2018-08-03 23:04:47 -04:00
|
|
|
|
public async Task SendFailedTwoFactorAttemptsEmailAsync(string email, DateTime utcNow, string ip)
|
2022-08-29 16:06:55 -04:00
|
|
|
|
{
|
2022-03-02 15:45:00 -06:00
|
|
|
|
var message = CreateDefaultMessage("Failed login attempts detected", email);
|
|
|
|
|
|
var model = new FailedAuthAttemptsModel()
|
2022-08-29 16:06:55 -04:00
|
|
|
|
{
|
2018-08-03 23:04:47 -04:00
|
|
|
|
TheDate = utcNow.ToLongDateString(),
|
2020-10-20 02:48:10 -04:00
|
|
|
|
TheTime = utcNow.ToShortTimeString(),
|
[AC-1191] TDE admin approval email (#3044)
* feat: add new command for updating request and emailing user, refs AC-1191
* feat: inject service with organization service collection extensions, refs AC-1191
* feat: add function to send admin approval email to mail services (interface/noop/handlebars), refs AC-1191
* feat: add html/text mail templates and add view model for email data, refs AC-1191
* feat: update org auth request controller to use new command during auth request update, refs AC-1191
* fix: dotnet format, refs AC-1191
* refactor: update user not found error, FirstOrDefault for enum type display name, refs AC-1191
* refactor: update user not found to log error instead of throws, refs AC-1191
* fix: remove whitespace lint errors, refs AC-1191
* refactor: update hardcoded UTC timezone string, refs AC-1191
* refactor: add unit test for new command, refs AC-1191
* refactor: improve enum name fallback and identifier string creation, refs AC-1191
* refactor: add addtional unit tests, refs AC-1191
* refactor: update success test to use more generated params, refs AC-1191
* fix: dotnet format...again, refs AC-1191
* refactor: make UTC display a constant for handlebars mail service, refs AC-1191
* refactor: update displayTypeIdentifer to displayTypeAndIdentifier for clarity, refs AC-1191
2023-07-06 10:03:49 -05:00
|
|
|
|
TimeZone = _utcTimeZoneDisplay,
|
2022-03-02 15:45:00 -06:00
|
|
|
|
IpAddress = ip,
|
Families for Enterprise (#1714)
* Create common test infrastructure project
* Add helpers to further type PlanTypes
* Enable testing of ASP.net MVC controllers
Controller properties have all kinds of validations in the background.
In general, we don't user properties on our Controllers, so the easiest
way to allow for Autofixture-based testing of our Controllers is to just
omit setting all properties on them.
* Workaround for broken MemberAutoDataAttribute
https://github.com/AutoFixture/AutoFixture/pull/1164 shows that only
the first test case is pulled for this attribute.
This is a workaround that populates the provided parameters, left to
right, using AutoFixture to populate any remaining.
* WIP: Organization sponsorship flow
* Add Attribute to use the Bit Autodata dependency chain
BitAutoDataAttribute is used to mark a Theory as autopopulating
parameters.
Extract common attribute methods to to a helper class. Cannot
inherit a common base, since both require inheriting from different
Xunit base classes to work.
* WIP: scaffolding for families for enterprise sponsorship flow
* Fix broken tests
* Create sponsorship offer (#1688)
* Initial db work (#1687)
* Add organization sponsorship databases to all providers
* Generalize create and update for database, specialize in code
* Add PlanSponsorshipType to db model
* Write valid json for test entries
* Initial scaffolding of emails (#1686)
* Initial scaffolding of emails
* Work on adding models for FamilyForEnterprise emails
* Switch verbage
* Put preliminary copy in emails
* Skip test
* Families for enterprise/stripe integrations (#1699)
* Add PlanSponsorshipType to static store
* Add sponsorship type to token and creates sponsorship
* PascalCase properties
* Require sponsorship for remove
* Create subscription sponsorship helper class
* Handle Sponsored subscription changes
* Add sponsorship id to subscription metadata
* Make sponsoring references nullable
This state indicates that a sponsorship has lapsed, but was not able to
be reverted for billing reasons
* WIP: Validate and remove subscriptions
* Update sponsorships on organization and org user delete
* Add friendly name to organization sponsorship
* Add sponsorship available boolean to orgDetails
* Add sponsorship service to DI
* Use userId to find org users
* Send f4e offer email
* Simplify names of f4e mail messages
* Fix Stripe org default tax rates
* Universal sponsorship redeem api
* Populate user in current context
* Add product type to organization details
* Use upgrade path to change sponsorship
Sponsorships need to be annual to match the GB add-on charge rate
* Use organization and auth to find organization sponsorship
* Add resend sponsorship offer api endpoint
* Fix double email send
* Fix sponsorship upgrade options
* Add is sponsored item to subscription response
* Add sponsorship validation to upcoming invoice webhook
* Add sponsorship validation to upcoming invoice webhook
* Fix organization delete sponsorship hooks
* Test org sponsorship service
* Fix sproc
* Create common test infrastructure project
* Add helpers to further type PlanTypes
* Enable testing of ASP.net MVC controllers
Controller properties have all kinds of validations in the background.
In general, we don't user properties on our Controllers, so the easiest
way to allow for Autofixture-based testing of our Controllers is to just
omit setting all properties on them.
* Workaround for broken MemberAutoDataAttribute
https://github.com/AutoFixture/AutoFixture/pull/1164 shows that only
the first test case is pulled for this attribute.
This is a workaround that populates the provided parameters, left to
right, using AutoFixture to populate any remaining.
* WIP: Organization sponsorship flow
* Add Attribute to use the Bit Autodata dependency chain
BitAutoDataAttribute is used to mark a Theory as autopopulating
parameters.
Extract common attribute methods to to a helper class. Cannot
inherit a common base, since both require inheriting from different
Xunit base classes to work.
* WIP: scaffolding for families for enterprise sponsorship flow
* Fix broken tests
* Create sponsorship offer (#1688)
* Initial db work (#1687)
* Add organization sponsorship databases to all providers
* Generalize create and update for database, specialize in code
* Add PlanSponsorshipType to db model
* Write valid json for test entries
* Initial scaffolding of emails (#1686)
* Initial scaffolding of emails
* Work on adding models for FamilyForEnterprise emails
* Switch verbage
* Put preliminary copy in emails
* Skip test
* Families for enterprise/stripe integrations (#1699)
* Add PlanSponsorshipType to static store
* Add sponsorship type to token and creates sponsorship
* PascalCase properties
* Require sponsorship for remove
* Create subscription sponsorship helper class
* Handle Sponsored subscription changes
* Add sponsorship id to subscription metadata
* Make sponsoring references nullable
This state indicates that a sponsorship has lapsed, but was not able to
be reverted for billing reasons
* WIP: Validate and remove subscriptions
* Update sponsorships on organization and org user delete
* Add friendly name to organization sponsorship
* Add sponsorship available boolean to orgDetails
* Add sponsorship service to DI
* Use userId to find org users
* Send f4e offer email
* Simplify names of f4e mail messages
* Fix Stripe org default tax rates
* Universal sponsorship redeem api
* Populate user in current context
* Add product type to organization details
* Use upgrade path to change sponsorship
Sponsorships need to be annual to match the GB add-on charge rate
* Use organization and auth to find organization sponsorship
* Add resend sponsorship offer api endpoint
* Fix double email send
* Fix sponsorship upgrade options
* Add is sponsored item to subscription response
* Add sponsorship validation to upcoming invoice webhook
* Add sponsorship validation to upcoming invoice webhook
* Fix organization delete sponsorship hooks
* Test org sponsorship service
* Fix sproc
* Fix build error
* Update emails
* Fix tests
* Skip local test
* Add newline
* Fix stripe subscription update
* Finish emails
* Skip test
* Fix unit tests
* Remove unused variable
* Fix unit tests
* Switch to handlebars ifs
* Remove ending email
* Remove reconfirmation template
* Switch naming convention
* Switch naming convention
* Fix migration
* Update copy and links
* Switch to using Guid in the method
* Remove unneeded css styles
* Add sql files to Sql.sqlproj
* Removed old comments
* Made name more verbose
* Fix SQL error
* Move unit tests to service
* Fix sp
* Revert "Move unit tests to service"
This reverts commit 1185bf3ec8ca36ccd75717ed2463adf8885159a6.
* Do repository validation in service layer
* Fix tests
* Fix merge conflicts and remove TODO
* Remove unneeded models
* Fix spacing and formatting
* Switch Org -> Organization
* Remove single use variables
* Switch method name
* Fix Controller
* Switch to obfuscating email
* Fix unit tests
Co-authored-by: Justin Baur <admin@justinbaur.com>
2021-11-19 16:25:06 -06:00
|
|
|
|
AffectedEmail = email
|
2022-08-29 16:06:55 -04:00
|
|
|
|
|
2022-08-29 15:53:48 -04:00
|
|
|
|
};
|
2023-04-14 13:25:56 -04:00
|
|
|
|
await AddMessageContentAsync(message, "Auth.FailedTwoFactorAttempts", model);
|
Families for Enterprise (#1714)
* Create common test infrastructure project
* Add helpers to further type PlanTypes
* Enable testing of ASP.net MVC controllers
Controller properties have all kinds of validations in the background.
In general, we don't user properties on our Controllers, so the easiest
way to allow for Autofixture-based testing of our Controllers is to just
omit setting all properties on them.
* Workaround for broken MemberAutoDataAttribute
https://github.com/AutoFixture/AutoFixture/pull/1164 shows that only
the first test case is pulled for this attribute.
This is a workaround that populates the provided parameters, left to
right, using AutoFixture to populate any remaining.
* WIP: Organization sponsorship flow
* Add Attribute to use the Bit Autodata dependency chain
BitAutoDataAttribute is used to mark a Theory as autopopulating
parameters.
Extract common attribute methods to to a helper class. Cannot
inherit a common base, since both require inheriting from different
Xunit base classes to work.
* WIP: scaffolding for families for enterprise sponsorship flow
* Fix broken tests
* Create sponsorship offer (#1688)
* Initial db work (#1687)
* Add organization sponsorship databases to all providers
* Generalize create and update for database, specialize in code
* Add PlanSponsorshipType to db model
* Write valid json for test entries
* Initial scaffolding of emails (#1686)
* Initial scaffolding of emails
* Work on adding models for FamilyForEnterprise emails
* Switch verbage
* Put preliminary copy in emails
* Skip test
* Families for enterprise/stripe integrations (#1699)
* Add PlanSponsorshipType to static store
* Add sponsorship type to token and creates sponsorship
* PascalCase properties
* Require sponsorship for remove
* Create subscription sponsorship helper class
* Handle Sponsored subscription changes
* Add sponsorship id to subscription metadata
* Make sponsoring references nullable
This state indicates that a sponsorship has lapsed, but was not able to
be reverted for billing reasons
* WIP: Validate and remove subscriptions
* Update sponsorships on organization and org user delete
* Add friendly name to organization sponsorship
* Add sponsorship available boolean to orgDetails
* Add sponsorship service to DI
* Use userId to find org users
* Send f4e offer email
* Simplify names of f4e mail messages
* Fix Stripe org default tax rates
* Universal sponsorship redeem api
* Populate user in current context
* Add product type to organization details
* Use upgrade path to change sponsorship
Sponsorships need to be annual to match the GB add-on charge rate
* Use organization and auth to find organization sponsorship
* Add resend sponsorship offer api endpoint
* Fix double email send
* Fix sponsorship upgrade options
* Add is sponsored item to subscription response
* Add sponsorship validation to upcoming invoice webhook
* Add sponsorship validation to upcoming invoice webhook
* Fix organization delete sponsorship hooks
* Test org sponsorship service
* Fix sproc
* Create common test infrastructure project
* Add helpers to further type PlanTypes
* Enable testing of ASP.net MVC controllers
Controller properties have all kinds of validations in the background.
In general, we don't user properties on our Controllers, so the easiest
way to allow for Autofixture-based testing of our Controllers is to just
omit setting all properties on them.
* Workaround for broken MemberAutoDataAttribute
https://github.com/AutoFixture/AutoFixture/pull/1164 shows that only
the first test case is pulled for this attribute.
This is a workaround that populates the provided parameters, left to
right, using AutoFixture to populate any remaining.
* WIP: Organization sponsorship flow
* Add Attribute to use the Bit Autodata dependency chain
BitAutoDataAttribute is used to mark a Theory as autopopulating
parameters.
Extract common attribute methods to to a helper class. Cannot
inherit a common base, since both require inheriting from different
Xunit base classes to work.
* WIP: scaffolding for families for enterprise sponsorship flow
* Fix broken tests
* Create sponsorship offer (#1688)
* Initial db work (#1687)
* Add organization sponsorship databases to all providers
* Generalize create and update for database, specialize in code
* Add PlanSponsorshipType to db model
* Write valid json for test entries
* Initial scaffolding of emails (#1686)
* Initial scaffolding of emails
* Work on adding models for FamilyForEnterprise emails
* Switch verbage
* Put preliminary copy in emails
* Skip test
* Families for enterprise/stripe integrations (#1699)
* Add PlanSponsorshipType to static store
* Add sponsorship type to token and creates sponsorship
* PascalCase properties
* Require sponsorship for remove
* Create subscription sponsorship helper class
* Handle Sponsored subscription changes
* Add sponsorship id to subscription metadata
* Make sponsoring references nullable
This state indicates that a sponsorship has lapsed, but was not able to
be reverted for billing reasons
* WIP: Validate and remove subscriptions
* Update sponsorships on organization and org user delete
* Add friendly name to organization sponsorship
* Add sponsorship available boolean to orgDetails
* Add sponsorship service to DI
* Use userId to find org users
* Send f4e offer email
* Simplify names of f4e mail messages
* Fix Stripe org default tax rates
* Universal sponsorship redeem api
* Populate user in current context
* Add product type to organization details
* Use upgrade path to change sponsorship
Sponsorships need to be annual to match the GB add-on charge rate
* Use organization and auth to find organization sponsorship
* Add resend sponsorship offer api endpoint
* Fix double email send
* Fix sponsorship upgrade options
* Add is sponsored item to subscription response
* Add sponsorship validation to upcoming invoice webhook
* Add sponsorship validation to upcoming invoice webhook
* Fix organization delete sponsorship hooks
* Test org sponsorship service
* Fix sproc
* Fix build error
* Update emails
* Fix tests
* Skip local test
* Add newline
* Fix stripe subscription update
* Finish emails
* Skip test
* Fix unit tests
* Remove unused variable
* Fix unit tests
* Switch to handlebars ifs
* Remove ending email
* Remove reconfirmation template
* Switch naming convention
* Switch naming convention
* Fix migration
* Update copy and links
* Switch to using Guid in the method
* Remove unneeded css styles
* Add sql files to Sql.sqlproj
* Removed old comments
* Made name more verbose
* Fix SQL error
* Move unit tests to service
* Fix sp
* Revert "Move unit tests to service"
This reverts commit 1185bf3ec8ca36ccd75717ed2463adf8885159a6.
* Do repository validation in service layer
* Fix tests
* Fix merge conflicts and remove TODO
* Remove unneeded models
* Fix spacing and formatting
* Switch Org -> Organization
* Remove single use variables
* Switch method name
* Fix Controller
* Switch to obfuscating email
* Fix unit tests
Co-authored-by: Justin Baur <admin@justinbaur.com>
2021-11-19 16:25:06 -06:00
|
|
|
|
message.Category = "FailedTwoFactorAttempts";
|
2021-11-09 16:37:32 +01:00
|
|
|
|
await _mailDeliveryService.SendEmailAsync(message);
|
2022-08-29 15:53:48 -04:00
|
|
|
|
}
|
|
|
|
|
|
|
[SG-147] Organization Domain Claiming Feature (#2704)
* [SG-696] Organization Domain Claiming DB Objects and Migrations (#2394)
* model organization domain claiming
* Added migration scripts and db objects for mssql
* create and implement sql repository abstraction
* Added ef migrations for mysql and postgres. Removed time without timezone in previous migration
* made update on sql migration to use create or alter statement
* removed active column from OrganizationDomain table and decided to go with the hard delete approach
* Ran dotnet restore evaluate
* created DNS service verification using DNSClient (#2401)
* [SG-678] Api Endpoints for Domain Claiming (#2430)
* Added stored procedure to read claimed domains
* Updated Organization Domain Repository to include method to get claimed domains
* Updated domain entity and added request model
* Implemented organization domain respository and regsitered it in the various extensions
* Added create endpoint, request, responses and command
* Added endpoint to get domain by domain entry id
* Ran lint fix
* Added new stored procedure to get domains by organizattion id
* Moved migration scripts to init migration and added new procedure
* Renamed from domainId to Id
* Added and implemented GetDomainByOrganizationId
* Completed GetDomainByOrgId endpoint and started work on verify domain endpoint
* Updated the OrganizationDomain update procedure
* Added delete command and include other endpoints in the controller
* Remove test item from controller
* Remove test item from controller
* Changed access to allow admin, owners and manage sso roles
* changed logic for setting the initial value for the NextRunCount
* Renamed NextRunCount to JobRunCount
* Renamed NextRunCount to JobRunCount on mysql
* Renamed NextRunCount to JobRunCount on postgres
* Removed chaining pattern and added logic to get next run date
* Lint fix
* Added stored procedure to get organization sso details by email address
* Added endpoint to get sso details of an organization with email
* Added organizationDomainRepository to OrganizationController test
* merged with master and fixed conflicts
* [SG-661] Background Domain Verification Service (#2455)
* Added stored procedure to read claimed domains
* Updated Organization Domain Repository to include method to get claimed domains
* Updated domain entity and added request model
* Implemented organization domain respository and regsitered it in the various extensions
* Added create endpoint, request, responses and command
* Added endpoint to get domain by domain entry id
* Ran lint fix
* Added new stored procedure to get domains by organizattion id
* Moved migration scripts to init migration and added new procedure
* Renamed from domainId to Id
* Added and implemented GetDomainByOrganizationId
* Completed GetDomainByOrgId endpoint and started work on verify domain endpoint
* Updated the OrganizationDomain update procedure
* Added delete command and include other endpoints in the controller
* Remove test item from controller
* Remove test item from controller
* Changed access to allow admin, owners and manage sso roles
* Added stored procedure to get unverified domains by nextrundate
* Renamed stored procedure name
* Added domain verification service interface
* Added GetManyByNextRunDate to repository
* Added verification domain service implementation
* changed logic for setting the initial value for the NextRunCount
* This commit should be signed using my SSH key
* Renamed NextRunCount to JobRunCount
* Renamed NextRunCount to JobRunCount on mysql
* Renamed NextRunCount to JobRunCount on postgres
* Removed chaining pattern and added logic to get next run date
* Lint fix
* Implemented EF core version on the repository
* Created background job implementation and logic
* popped stash
* Updated stored procedure and EF script
* Lint fix
* Added logic to set next job count and the next run date when a verification is false
* Added logic to set next job count and the next run date when a verification is false
* Updated stored procedure name on repository
* Removed test trigger
* Lint fix
* Added trigger for job
* Added job count update after successful domain verification
* Lint fix
* Lint fix
* [SG-682] Add Event Log Entries to Organization Domain (#2492)
* Added domain name property to Event related objects
* Added organization domain claiming event types
* Created migration script and updated related event scripts to include domanName
* Added EF Migrations
* Renamed postres script file extension
* Added DomainName property to response model
* Added abstraction to interface
* Added system name to enum
* dotnet formattinfg fix
* Added events to organization domain actions
* Added LastCheckedDate property to domain
* Migrations and stored procedure updates with new column
* Added new stored procedure to get domain by org id and domain name
* Log organization domain event abstract method
* Ef migrattion to add new LastCheckedDate column
* Added duplicate domain exception
* Modified create command to include domain verification and last checked date and renamed methods used
* removed variable
* changed service lifetime
* Renamed trigger
* Initialed property in constructor
* Ensured domain name is stored as lower case
* Fixed suggestions from review
* Fixed suggestions from review
* Return Conflict Status on Organization Domain APIs (#2498)
* Added conflict response to end point to help translate error message on the client better
* Added conflict response to end point to help translate error message on the client better
* Set message with exception message or generic message
* Added last check date to response model (#2499)
* Fix/Check to throw exception when domain is claimed by another organization (#2503)
* Added check to ensure domain claimed by another organization cannot be verified
* Made error message consistent
* [SG-660] Organization Domain Maintenance (#2502)
* Added email template
* Mail service abstraction and implementation
* Mail template model
* Initial delete job commit
* Added SPs to get all unverifed domains after 72 hours and another to delete unverified domains after 7 days
* Moved all organization domain scripts to single file
* Added new scripts implementation for sqlserver and EF core
* Renamed service
* Formatting fix
* Added background service to send warning email and delete expired domains
* Renamed variable
* Added implementation for email warning to organization admins and for deleting expired domains after 7 days
* Added formatting
* Modified read if expired script to limit result to 4 days
* Added send mail abstract method and implementation
* Model used in build mail body
* Completed maintenace service
* Added comment to make logic clear
* Fixed cron expression (#2505)
* Modified procedure and methods to handle flexible verification adn expiration period (#2517)
* Merged with master
* [SG-908] Unit Tests for Organization Domain Claiming Feature (#2522)
* added test controlleer class
* added unit test for create command
* Added query tests
* Added tests for delete and verify command
* Formated code and added some more unit tests
* Fixed lint
* Added log event assertion to create command tests
* Added log event assertion to delete command tests
* Added unit tests for organization domain controller
* Added unit tests for organization domain service
* Modified test after merge
* fixed comment
* fixed comment
* fixed lint
* Defect/SG-977 - Org domain event logs missing details (#2573)
* SG-977 - (1) Refactor EventSystemUser.SSO to be EventSystemUser.DomainVerification to better match SCIM property and for easier display and translation on web client (2) Add new DeviceType of Server to be used on SCIM and Domain Verification logs so event log will show Server as client.
* SG-977 - SCIM bugfix - Restoring / Revoking user access via Jumpcloud activation / suspension did not properly log the events as SCIM events so the client side showed Unknown for both Client and Member.
* Run autoformat to fix lint errors
* SG-977 - Fixed broken test due to new device type logic in event service
* SG-976 - Add admin log and clean up log verbiage for domain verification (#2574)
* SG-976 - Add admin log and clean up log verbiage for domain verification
* SG-976 - (1) Use logInformation extension without exception (2) Clarify verbiage of logs
* SG-955 - On domain verification error or failure, set last checked da… (#2541)
* SG-955 - On domain verification error or failure, set last checked date on the org domain.
* SG-955 - Refactoring VerifyOrganizationDomain event logging to avoid duplication and increase efficiency (based on Gbubemi's PR feedback)
* Org Domain Background Verification service - set last checked date (#2599)
* Refactored OrganizationDomain repository to work with latest changes on code base
* Fixed formatting
* [SG-957] Cannot Delete Organizations due to FK Constraint (#2602)
* Added stored procedure to fix FX contstraint issue when deleting an organization
* Update stored procedures related to organization delete with OrganizationDomain_OrganizationDelete SP
* Fixed formatting
* Updated SP
* SG-990 - Log expired domains that are going to be deleted.
* Fix lint errors with auto format
* /home/runner/work/server/server/src/Core/OrganizationFeatures/OrganizationServiceCollectionExtensions.cs(107,2): error FINALNEWLINE: Fix final newline. Insert '\n'.
* Added missing bracket to fix compile error.
* Added imports for Domain Claiming classes that were lost on merge.
* Fixing broken unit tests + adding proper behavior for newly added SCIM logic changing device type
* Fix lint errors again
* Included domain name set in constructor (#2618)
* [SG-1001] Error Thrown When Verifying Sub Domains (#2621)
* Renamed exception to a more generic name that receives error message from the dns client and also added updates to job count and next run date
* Improved error logs by adding dns client error message
* Fixed formatting
* [SG-1001] Added event logs when a domain is not verified due to thrown exception (#2623)
* Added eevent logs when a domain is not verified due to thrown exception
* Fixed formatting
* Org Domain Verification - Small refactor to improve method/model name… (#2641)
* Org Domain Verification - Small refactor to improve method/model names and method locations - required refactoring of controller routes (I confirmed all behavior still functional)
* Fixed organization test controller issue
* Fixed lint
* Autoformat org domain controller
* Removing whitespace for lint argh, why does Rider not do this.
---------
Co-authored-by: gbubemismith <gsmithwalter@gmail.com>
* Tweak name of Request model to match Response model for ClaimedOrgDomain call
* [SG-1009] Users with Custom Role and "Manage SSO" permission don't receive verification failed email (#2645)
* Modified condition to pick up unverified domains after said period
* Fix to get emails of custom users with manage sso rights
* Formatted code
* Removed return that made background job exit on successful validation (#2648)
* [SG-1014] Unit Tests for Get Organization Sso Details (#2655)
* Added unit tests for GetOrgDomainSsoDetails
* renamed variable
* Adjust OrganizationDomainSsoDetails_ReadByEmail to use outer join so … (#2657)
* Adjust OrganizationDomainSsoDetails_ReadByEmail to use outer join so that claimed domain results will come back if an org has not yet setup a policy
* Removed migration as not needed
* Updated OrganizationDomainSsoDetails_ReadByEmail from original creation migration to use outer join & handle null policy results (and still return results)
* Fixed lint formatting
---------
Co-authored-by: Jared Snider <116684653+JaredSnider-Bitwarden@users.noreply.github.com>
Co-authored-by: Jared Snider <jsnider@bitwarden.com>
Co-authored-by: Todd Martin <tmartin@bitwarden.com>
2023-02-15 14:26:41 -05:00
|
|
|
|
public async Task SendUnverifiedOrganizationDomainEmailAsync(IEnumerable<string> adminEmails, string organizationId, string domainName)
|
|
|
|
|
|
{
|
|
|
|
|
|
var message = CreateDefaultMessage("Domain not verified", adminEmails);
|
|
|
|
|
|
var model = new OrganizationDomainUnverifiedViewModel
|
|
|
|
|
|
{
|
|
|
|
|
|
Url = $"{_globalSettings.BaseServiceUri.VaultWithHash}/organizations/{organizationId}/settings/domain-verification",
|
|
|
|
|
|
DomainName = domainName
|
|
|
|
|
|
};
|
|
|
|
|
|
await AddMessageContentAsync(message, "OrganizationDomainUnverified", model);
|
|
|
|
|
|
message.Category = "UnverifiedOrganizationDomain";
|
|
|
|
|
|
await _mailDeliveryService.SendEmailAsync(message);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
[AC-1191] TDE admin approval email (#3044)
* feat: add new command for updating request and emailing user, refs AC-1191
* feat: inject service with organization service collection extensions, refs AC-1191
* feat: add function to send admin approval email to mail services (interface/noop/handlebars), refs AC-1191
* feat: add html/text mail templates and add view model for email data, refs AC-1191
* feat: update org auth request controller to use new command during auth request update, refs AC-1191
* fix: dotnet format, refs AC-1191
* refactor: update user not found error, FirstOrDefault for enum type display name, refs AC-1191
* refactor: update user not found to log error instead of throws, refs AC-1191
* fix: remove whitespace lint errors, refs AC-1191
* refactor: update hardcoded UTC timezone string, refs AC-1191
* refactor: add unit test for new command, refs AC-1191
* refactor: improve enum name fallback and identifier string creation, refs AC-1191
* refactor: add addtional unit tests, refs AC-1191
* refactor: update success test to use more generated params, refs AC-1191
* fix: dotnet format...again, refs AC-1191
* refactor: make UTC display a constant for handlebars mail service, refs AC-1191
* refactor: update displayTypeIdentifer to displayTypeAndIdentifier for clarity, refs AC-1191
2023-07-06 10:03:49 -05:00
|
|
|
|
public async Task SendTrustedDeviceAdminApprovalEmailAsync(string email, DateTime utcNow, string ip,
|
|
|
|
|
|
string deviceTypeAndIdentifier)
|
|
|
|
|
|
{
|
|
|
|
|
|
var message = CreateDefaultMessage("Login request approved", email);
|
|
|
|
|
|
var model = new TrustedDeviceAdminApprovalViewModel
|
|
|
|
|
|
{
|
|
|
|
|
|
TheDate = utcNow.ToLongDateString(),
|
|
|
|
|
|
TheTime = utcNow.ToShortTimeString(),
|
|
|
|
|
|
TimeZone = _utcTimeZoneDisplay,
|
|
|
|
|
|
IpAddress = ip,
|
|
|
|
|
|
DeviceType = deviceTypeAndIdentifier,
|
|
|
|
|
|
};
|
|
|
|
|
|
await AddMessageContentAsync(message, "Auth.TrustedDeviceAdminApproval", model);
|
|
|
|
|
|
message.Category = "TrustedDeviceAdminApproval";
|
|
|
|
|
|
await _mailDeliveryService.SendEmailAsync(message);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2022-06-23 10:44:41 -05:00
|
|
|
|
private static string GetUserIdentifier(string email, string userName)
|
|
|
|
|
|
{
|
|
|
|
|
|
return string.IsNullOrEmpty(userName) ? email : CoreHelpers.SanitizeForEmail(userName, false);
|
2018-08-03 23:04:47 -04:00
|
|
|
|
}
|
|
|
|
|
|
}
|
[AC-1191] TDE admin approval email (#3044)
* feat: add new command for updating request and emailing user, refs AC-1191
* feat: inject service with organization service collection extensions, refs AC-1191
* feat: add function to send admin approval email to mail services (interface/noop/handlebars), refs AC-1191
* feat: add html/text mail templates and add view model for email data, refs AC-1191
* feat: update org auth request controller to use new command during auth request update, refs AC-1191
* fix: dotnet format, refs AC-1191
* refactor: update user not found error, FirstOrDefault for enum type display name, refs AC-1191
* refactor: update user not found to log error instead of throws, refs AC-1191
* fix: remove whitespace lint errors, refs AC-1191
* refactor: update hardcoded UTC timezone string, refs AC-1191
* refactor: add unit test for new command, refs AC-1191
* refactor: improve enum name fallback and identifier string creation, refs AC-1191
* refactor: add addtional unit tests, refs AC-1191
* refactor: update success test to use more generated params, refs AC-1191
* fix: dotnet format...again, refs AC-1191
* refactor: make UTC display a constant for handlebars mail service, refs AC-1191
* refactor: update displayTypeIdentifer to displayTypeAndIdentifier for clarity, refs AC-1191
2023-07-06 10:03:49 -05:00
|
|
|
|
|