diff --git a/Lombiq.Hosting.Tenants.Maintenance/Maintenance/ChangeUserSensitiveContent/ChangeUserSensitiveContentMaintenanceOptions.cs b/Lombiq.Hosting.Tenants.Maintenance/Maintenance/ChangeUserSensitiveContent/ChangeUserSensitiveContentMaintenanceOptions.cs index 64890e5c..32477d35 100644 --- a/Lombiq.Hosting.Tenants.Maintenance/Maintenance/ChangeUserSensitiveContent/ChangeUserSensitiveContentMaintenanceOptions.cs +++ b/Lombiq.Hosting.Tenants.Maintenance/Maintenance/ChangeUserSensitiveContent/ChangeUserSensitiveContentMaintenanceOptions.cs @@ -4,4 +4,5 @@ public class ChangeUserSensitiveContentMaintenanceOptions { public bool IsEnabled { get; set; } public string TenantNames { get; set; } + public string EmailExcludePattern { get; set; } = ".+@lombiq.com$"; } diff --git a/Lombiq.Hosting.Tenants.Maintenance/Maintenance/ChangeUserSensitiveContent/ChangeUserSensitiveContentMaintenanceProvider.cs b/Lombiq.Hosting.Tenants.Maintenance/Maintenance/ChangeUserSensitiveContent/ChangeUserSensitiveContentMaintenanceProvider.cs index 0327d3f4..92a009fe 100644 --- a/Lombiq.Hosting.Tenants.Maintenance/Maintenance/ChangeUserSensitiveContent/ChangeUserSensitiveContentMaintenanceProvider.cs +++ b/Lombiq.Hosting.Tenants.Maintenance/Maintenance/ChangeUserSensitiveContent/ChangeUserSensitiveContentMaintenanceProvider.cs @@ -9,6 +9,7 @@ using RandomNameGeneratorLibrary; using System; using System.Linq; +using System.Text.RegularExpressions; using System.Threading.Tasks; using YesSql; using static Lombiq.HelpfulLibraries.OrchardCore.Users.PasswordHelper; @@ -49,7 +50,7 @@ public override async Task ExecuteAsync(MaintenanceTaskExecutionContext context) var users = await _session.Query().ListAsync(); foreach (var user in users.Where(user => - !user.Email.Trim().EndsWith($"@lombiq.com", StringComparison.InvariantCulture))) + !Regex.IsMatch(user.Email.Trim(), _options.Value.EmailExcludePattern, RegexOptions.None, TimeSpan.FromMilliseconds(400)))) { var firstName = randomNameGenerator.GenerateRandomFirstName(); var lastName = randomNameGenerator.GenerateRandomLastName(); diff --git a/Lombiq.Hosting.Tenants.Maintenance/Readme.md b/Lombiq.Hosting.Tenants.Maintenance/Readme.md index 0a9ca256..3d526216 100644 --- a/Lombiq.Hosting.Tenants.Maintenance/Readme.md +++ b/Lombiq.Hosting.Tenants.Maintenance/Readme.md @@ -145,9 +145,12 @@ The following configuration should be used to allow the maintenance to run: "Lombiq_Hosting_Tenants_Maintenance": { "ChangeUserSensitiveContent": { "IsEnabled": true, - "TenantNames": "Default, Tenant1, Tenant2" + "TenantNames": "Default, Tenant1, Tenant2", + "EmailExcludePattern": ".+@(lombiq.com|example.com)$" } } } } ``` + +Any user accounts with an e-mail matching the `EmailExcludePattern` regex will not be depersonalized. \ No newline at end of file