From b5351d0483f2ead43df3090cdf6cf3a487ff8ab8 Mon Sep 17 00:00:00 2001 From: colin Date: Mon, 3 Mar 2025 20:44:09 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E5=88=86=E7=A6=BB=E8=B4=A6=E6=88=B7?= =?UTF-8?q?=E9=82=AE=E4=BB=B6=E5=8F=91=E9=80=81=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Account/Emailing/AccountEmailSender.cs | 92 ------------ .../FodyWeavers.xml | 3 + .../FodyWeavers.xsd | 30 ++++ .../LINGYUN.Abp.Account.Emailing.csproj | 28 ++++ .../Emailing/AbpAccountEmailingModule.cs | 29 ++++ .../Account/Emailing/AccountEmailSender.cs | 137 ++++++++++++++++++ .../Abp/Account/Emailing}/AccountUrlNames.cs | 14 +- .../Emailing/IAccountEmailConfirmSender.cs | 32 ++-- .../Emailing/IAccountEmailVerifySender.cs | 12 +- .../Localization/AccountEmailingResource.cs | 8 + .../Emailing}/Localization/Resources/en.json | 0 .../Localization/Resources/zh-Hans.json | 0 .../Templates/AccountEmailTemplates.cs | 13 ++ .../AccountTemplateDefinitionProvider.cs | 32 ++++ .../Emailing/Templates/MailConfirm.tpl | 7 + .../Emailing/Templates/MailSecurityVerify.tpl | 5 + .../LINGYUN.Abp.Account.Templates.csproj | 7 +- .../AbpAccountEmailingModule.cs} | 56 +++---- .../Emailing/Localization/Resources/en.json | 16 ++ .../Localization/Resources/zh-Hans.json | 16 ++ .../Templates/AccountEmailTemplates.cs | 18 +-- .../AccountTemplateDefinitionProvider.cs | 14 +- 22 files changed, 403 insertions(+), 166 deletions(-) delete mode 100644 aspnet-core/modules/account/LINGYUN.Abp.Account.Application/LINGYUN/Abp/Account/Emailing/AccountEmailSender.cs create mode 100644 aspnet-core/modules/account/LINGYUN.Abp.Account.Emailing/FodyWeavers.xml create mode 100644 aspnet-core/modules/account/LINGYUN.Abp.Account.Emailing/FodyWeavers.xsd create mode 100644 aspnet-core/modules/account/LINGYUN.Abp.Account.Emailing/LINGYUN.Abp.Account.Emailing.csproj create mode 100644 aspnet-core/modules/account/LINGYUN.Abp.Account.Emailing/LINGYUN/Abp/Account/Emailing/AbpAccountEmailingModule.cs create mode 100644 aspnet-core/modules/account/LINGYUN.Abp.Account.Emailing/LINGYUN/Abp/Account/Emailing/AccountEmailSender.cs rename aspnet-core/modules/account/{LINGYUN.Abp.Account.Application/LINGYUN/Abp/Account => LINGYUN.Abp.Account.Emailing/LINGYUN/Abp/Account/Emailing}/AccountUrlNames.cs (80%) rename aspnet-core/modules/account/{LINGYUN.Abp.Account.Application => LINGYUN.Abp.Account.Emailing}/LINGYUN/Abp/Account/Emailing/IAccountEmailConfirmSender.cs (57%) rename aspnet-core/modules/account/{LINGYUN.Abp.Account.Application => LINGYUN.Abp.Account.Emailing}/LINGYUN/Abp/Account/Emailing/IAccountEmailVerifySender.cs (97%) create mode 100644 aspnet-core/modules/account/LINGYUN.Abp.Account.Emailing/LINGYUN/Abp/Account/Emailing/Localization/AccountEmailingResource.cs rename aspnet-core/modules/account/{LINGYUN.Abp.Account.Templates/LINGYUN/Abp/Account/Templates => LINGYUN.Abp.Account.Emailing/LINGYUN/Abp/Account/Emailing}/Localization/Resources/en.json (100%) rename aspnet-core/modules/account/{LINGYUN.Abp.Account.Templates/LINGYUN/Abp/Account/Templates => LINGYUN.Abp.Account.Emailing/LINGYUN/Abp/Account/Emailing}/Localization/Resources/zh-Hans.json (100%) create mode 100644 aspnet-core/modules/account/LINGYUN.Abp.Account.Emailing/LINGYUN/Abp/Account/Emailing/Templates/AccountEmailTemplates.cs create mode 100644 aspnet-core/modules/account/LINGYUN.Abp.Account.Emailing/LINGYUN/Abp/Account/Emailing/Templates/AccountTemplateDefinitionProvider.cs create mode 100644 aspnet-core/modules/account/LINGYUN.Abp.Account.Emailing/LINGYUN/Abp/Account/Emailing/Templates/MailConfirm.tpl create mode 100644 aspnet-core/modules/account/LINGYUN.Abp.Account.Emailing/LINGYUN/Abp/Account/Emailing/Templates/MailSecurityVerify.tpl rename aspnet-core/modules/account/LINGYUN.Abp.Account.Templates/LINGYUN/Abp/Account/{Templates/AbpAccountTemplatesModule.cs => Emailing/AbpAccountEmailingModule.cs} (67%) create mode 100644 aspnet-core/modules/account/LINGYUN.Abp.Account.Templates/LINGYUN/Abp/Account/Emailing/Localization/Resources/en.json create mode 100644 aspnet-core/modules/account/LINGYUN.Abp.Account.Templates/LINGYUN/Abp/Account/Emailing/Localization/Resources/zh-Hans.json diff --git a/aspnet-core/modules/account/LINGYUN.Abp.Account.Application/LINGYUN/Abp/Account/Emailing/AccountEmailSender.cs b/aspnet-core/modules/account/LINGYUN.Abp.Account.Application/LINGYUN/Abp/Account/Emailing/AccountEmailSender.cs deleted file mode 100644 index e14118a2c..000000000 --- a/aspnet-core/modules/account/LINGYUN.Abp.Account.Application/LINGYUN/Abp/Account/Emailing/AccountEmailSender.cs +++ /dev/null @@ -1,92 +0,0 @@ -using LINGYUN.Abp.Account.Emailing.Templates; -using Microsoft.Extensions.Localization; -using System; -using System.Collections.Generic; -using System.Diagnostics; -using System.Text.Encodings.Web; -using System.Threading.Tasks; -using Volo.Abp.Account.Emailing; -using Volo.Abp.Account.Localization; -using Volo.Abp.DependencyInjection; -using Volo.Abp.Emailing; -using Volo.Abp.Identity; -using Volo.Abp.MultiTenancy; -using Volo.Abp.TextTemplating; -using Volo.Abp.UI.Navigation.Urls; - -namespace LINGYUN.Abp.Account.Emailing; - -[Dependency(ReplaceServices = true)] -[ExposeServices( - typeof(IAccountEmailConfirmSender), - typeof(IAccountEmailVerifySender), - typeof(IAccountEmailer), - typeof(AccountEmailSender))] -public class AccountEmailSender : - AccountEmailer, - IAccountEmailConfirmSender, - IAccountEmailVerifySender, - ITransientDependency -{ - public AccountEmailSender( - IEmailSender emailSender, - ITemplateRenderer templateRenderer, - IStringLocalizer accountLocalizer, - IAppUrlProvider appUrlProvider, - ICurrentTenant currentTenant) - : base(emailSender, templateRenderer, accountLocalizer, appUrlProvider, currentTenant) - { - } - - public async virtual Task SendMailLoginVerifyCodeAsync( - string code, - string userName, - string emailAddress) - { - var emailContent = await TemplateRenderer.RenderAsync( - AccountEmailTemplates.MailSecurityVerifyLink, - new { code = code, user = userName } - ); - - await EmailSender.SendAsync( - emailAddress, - StringLocalizer["MailSecurityVerify"], - emailContent - ); - } - - public async virtual Task SendEmailConfirmLinkAsync( - IdentityUser user, - string confirmToken, - string appName, - string returnUrl = null, - string returnUrlHash = null) - { - Debug.Assert(CurrentTenant.Id == user.TenantId, "This method can only work for current tenant!"); - - var url = await AppUrlProvider.GetUrlAsync(appName, AccountUrlNames.EmailConfirm); - - var link = $"{url}?userId={user.Id}&{TenantResolverConsts.DefaultTenantKey}={user.TenantId}&confirmToken={confirmToken}"; - - if (!returnUrl.IsNullOrEmpty()) - { - link += "&returnUrl=" + NormalizeReturnUrl(returnUrl); - } - - if (!returnUrlHash.IsNullOrEmpty()) - { - link += "&returnUrlHash=" + returnUrlHash; - } - - var emailContent = await TemplateRenderer.RenderAsync( - AccountEmailTemplates.MailConfirmLink, - new { link = link } - ); - - await EmailSender.SendAsync( - user.Email, - StringLocalizer["EmailConfirm"], - emailContent - ); - } -} diff --git a/aspnet-core/modules/account/LINGYUN.Abp.Account.Emailing/FodyWeavers.xml b/aspnet-core/modules/account/LINGYUN.Abp.Account.Emailing/FodyWeavers.xml new file mode 100644 index 000000000..1715698cc --- /dev/null +++ b/aspnet-core/modules/account/LINGYUN.Abp.Account.Emailing/FodyWeavers.xml @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/aspnet-core/modules/account/LINGYUN.Abp.Account.Emailing/FodyWeavers.xsd b/aspnet-core/modules/account/LINGYUN.Abp.Account.Emailing/FodyWeavers.xsd new file mode 100644 index 000000000..3f3946e28 --- /dev/null +++ b/aspnet-core/modules/account/LINGYUN.Abp.Account.Emailing/FodyWeavers.xsd @@ -0,0 +1,30 @@ + + + + + + + + + + + + + + + 'true' to run assembly verification (PEVerify) on the target assembly after all weavers have been executed. + + + + + A comma-separated list of error codes that can be safely ignored in assembly verification. + + + + + 'false' to turn off automatic generation of the XML Schema file. + + + + + \ No newline at end of file diff --git a/aspnet-core/modules/account/LINGYUN.Abp.Account.Emailing/LINGYUN.Abp.Account.Emailing.csproj b/aspnet-core/modules/account/LINGYUN.Abp.Account.Emailing/LINGYUN.Abp.Account.Emailing.csproj new file mode 100644 index 000000000..01b39652a --- /dev/null +++ b/aspnet-core/modules/account/LINGYUN.Abp.Account.Emailing/LINGYUN.Abp.Account.Emailing.csproj @@ -0,0 +1,28 @@ + + + + + + + netstandard2.0;netstandard2.1;net8.0;net9.0 + LINGYUN.Abp.Account.Emailing + LINGYUN.Abp.Account.Emailing + false + false + false + + + + + + + + + + + + + + + + diff --git a/aspnet-core/modules/account/LINGYUN.Abp.Account.Emailing/LINGYUN/Abp/Account/Emailing/AbpAccountEmailingModule.cs b/aspnet-core/modules/account/LINGYUN.Abp.Account.Emailing/LINGYUN/Abp/Account/Emailing/AbpAccountEmailingModule.cs new file mode 100644 index 000000000..a8328c793 --- /dev/null +++ b/aspnet-core/modules/account/LINGYUN.Abp.Account.Emailing/LINGYUN/Abp/Account/Emailing/AbpAccountEmailingModule.cs @@ -0,0 +1,29 @@ +using LINGYUN.Abp.Account.Emailing.Localization; +using Volo.Abp.Emailing; +using Volo.Abp.Localization; +using Volo.Abp.Modularity; +using Volo.Abp.UI.Navigation; +using Volo.Abp.VirtualFileSystem; + +namespace LINGYUN.Abp.Account.Emailing; + +[DependsOn( + typeof(AbpEmailingModule), + typeof(AbpUiNavigationModule))] +public class AbpAccountEmailingModule : AbpModule +{ + public override void ConfigureServices(ServiceConfigurationContext context) + { + Configure(options => + { + options.FileSets.AddEmbedded(); + }); + + Configure(options => + { + options.Resources + .Add("en") + .AddVirtualJson("/LINGYUN/Abp/Account/Emailing/Localization/Resources"); + }); + } +} diff --git a/aspnet-core/modules/account/LINGYUN.Abp.Account.Emailing/LINGYUN/Abp/Account/Emailing/AccountEmailSender.cs b/aspnet-core/modules/account/LINGYUN.Abp.Account.Emailing/LINGYUN/Abp/Account/Emailing/AccountEmailSender.cs new file mode 100644 index 000000000..df1837b2a --- /dev/null +++ b/aspnet-core/modules/account/LINGYUN.Abp.Account.Emailing/LINGYUN/Abp/Account/Emailing/AccountEmailSender.cs @@ -0,0 +1,137 @@ +using LINGYUN.Abp.Account.Emailing.Localization; +using LINGYUN.Abp.Account.Emailing.Templates; +using Microsoft.Extensions.Localization; +using System; +using System.Collections.Generic; +using System.Diagnostics; +using System.Text.Encodings.Web; +using System.Threading.Tasks; +using System.Web; +using Volo.Abp.DependencyInjection; +using Volo.Abp.Emailing; +using Volo.Abp.MultiTenancy; +using Volo.Abp.TextTemplating; +using Volo.Abp.UI.Navigation.Urls; + +namespace LINGYUN.Abp.Account.Emailing; + +[Dependency(ReplaceServices = true)] +[ExposeServices( + typeof(IAccountEmailConfirmSender), + typeof(IAccountEmailVerifySender), + typeof(AccountEmailSender))] +public class AccountEmailSender : + IAccountEmailConfirmSender, + IAccountEmailVerifySender, + ITransientDependency +{ + protected ITemplateRenderer TemplateRenderer { get; } + protected IEmailSender EmailSender { get; } + protected IStringLocalizer StringLocalizer { get; } + protected IAppUrlProvider AppUrlProvider { get; } + protected ICurrentTenant CurrentTenant { get; } + + public AccountEmailSender( + IEmailSender emailSender, + ICurrentTenant currentTenant, + IAppUrlProvider appUrlProvider, + ITemplateRenderer templateRenderer, + IStringLocalizer accountLocalizer) + { + EmailSender = emailSender; + CurrentTenant = currentTenant; + AppUrlProvider = appUrlProvider; + StringLocalizer = accountLocalizer; + TemplateRenderer = templateRenderer; + } + + public async virtual Task SendMailLoginVerifyCodeAsync( + string code, + string userName, + string emailAddress) + { + var emailContent = await TemplateRenderer.RenderAsync( + AccountEmailTemplates.MailSecurityVerifyLink, + new { code = code, user = userName } + ); + + await EmailSender.SendAsync( + emailAddress, + StringLocalizer["MailSecurityVerify"], + emailContent + ); + } + + public async virtual Task SendEmailConfirmLinkAsync( + Guid userId, + string userEmail, + string confirmToken, + string appName, + string returnUrl = null, + string returnUrlHash = null, + Guid? userTenantId = null) + { + Debug.Assert(CurrentTenant.Id == userTenantId, "This method can only work for current tenant!"); + + var url = await AppUrlProvider.GetUrlAsync(appName, AccountUrlNames.EmailConfirm); + + var link = $"{url}?userId={userId}&{TenantResolverConsts.DefaultTenantKey}={userTenantId}&confirmToken={UrlEncoder.Default.Encode(confirmToken)}"; + + if (!returnUrl.IsNullOrEmpty()) + { + link += "&returnUrl=" + NormalizeReturnUrl(returnUrl); + } + + if (!returnUrlHash.IsNullOrEmpty()) + { + link += "&returnUrlHash=" + returnUrlHash; + } + + var emailContent = await TemplateRenderer.RenderAsync( + AccountEmailTemplates.MailConfirmLink, + new { link = link } + ); + + await EmailSender.SendAsync( + userEmail, + StringLocalizer["EmailConfirm"], + emailContent + ); + } + + protected virtual string NormalizeReturnUrl(string returnUrl) + { + if (returnUrl.IsNullOrEmpty()) + { + return returnUrl; + } + + //Handling openid connect login + if (returnUrl.StartsWith("/connect/authorize/callback", StringComparison.OrdinalIgnoreCase)) + { + if (returnUrl.Contains("?")) + { + var queryPart = returnUrl.Split('?')[1]; + var queryParameters = queryPart.Split('&'); + foreach (var queryParameter in queryParameters) + { + if (queryParameter.Contains("=")) + { + var queryParam = queryParameter.Split('='); + if (queryParam[0] == "redirect_uri") + { + return HttpUtility.UrlDecode(queryParam[1]); + } + } + } + } + } + + if (returnUrl.StartsWith("/connect/authorize?", StringComparison.OrdinalIgnoreCase)) + { + return HttpUtility.UrlEncode(returnUrl); + } + + return returnUrl; + } +} diff --git a/aspnet-core/modules/account/LINGYUN.Abp.Account.Application/LINGYUN/Abp/Account/AccountUrlNames.cs b/aspnet-core/modules/account/LINGYUN.Abp.Account.Emailing/LINGYUN/Abp/Account/Emailing/AccountUrlNames.cs similarity index 80% rename from aspnet-core/modules/account/LINGYUN.Abp.Account.Application/LINGYUN/Abp/Account/AccountUrlNames.cs rename to aspnet-core/modules/account/LINGYUN.Abp.Account.Emailing/LINGYUN/Abp/Account/Emailing/AccountUrlNames.cs index e09c4c583..040f3d0eb 100644 --- a/aspnet-core/modules/account/LINGYUN.Abp.Account.Application/LINGYUN/Abp/Account/AccountUrlNames.cs +++ b/aspnet-core/modules/account/LINGYUN.Abp.Account.Emailing/LINGYUN/Abp/Account/Emailing/AccountUrlNames.cs @@ -1,7 +1,7 @@ -namespace LINGYUN.Abp.Account; - -public static class AccountUrlNames -{ - public const string EmailConfirm = "Abp.Account.EmailConfirm"; - public const string EmailVerifyLogin = "Abp.Account.EmailVerifyLogin"; -} +namespace LINGYUN.Abp.Account.Emailing; + +public static class AccountUrlNames +{ + public const string EmailConfirm = "Abp.Account.EmailConfirm"; + public const string EmailVerifyLogin = "Abp.Account.EmailVerifyLogin"; +} diff --git a/aspnet-core/modules/account/LINGYUN.Abp.Account.Application/LINGYUN/Abp/Account/Emailing/IAccountEmailConfirmSender.cs b/aspnet-core/modules/account/LINGYUN.Abp.Account.Emailing/LINGYUN/Abp/Account/Emailing/IAccountEmailConfirmSender.cs similarity index 57% rename from aspnet-core/modules/account/LINGYUN.Abp.Account.Application/LINGYUN/Abp/Account/Emailing/IAccountEmailConfirmSender.cs rename to aspnet-core/modules/account/LINGYUN.Abp.Account.Emailing/LINGYUN/Abp/Account/Emailing/IAccountEmailConfirmSender.cs index 36a2427a9..6a2f693f4 100644 --- a/aspnet-core/modules/account/LINGYUN.Abp.Account.Application/LINGYUN/Abp/Account/Emailing/IAccountEmailConfirmSender.cs +++ b/aspnet-core/modules/account/LINGYUN.Abp.Account.Emailing/LINGYUN/Abp/Account/Emailing/IAccountEmailConfirmSender.cs @@ -1,15 +1,17 @@ -using System.Threading.Tasks; -using Volo.Abp.Identity; - -namespace LINGYUN.Abp.Account.Emailing; - -public interface IAccountEmailConfirmSender -{ - Task SendEmailConfirmLinkAsync( - IdentityUser user, - string confirmToken, - string appName, - string returnUrl = null, - string returnUrlHash = null - ); -} +using System; +using System.Threading.Tasks; + +namespace LINGYUN.Abp.Account.Emailing; + +public interface IAccountEmailConfirmSender +{ + Task SendEmailConfirmLinkAsync( + Guid userId, + string userEmail, + string confirmToken, + string appName, + string returnUrl = null, + string returnUrlHash = null, + Guid? userTenantId = null + ); +} diff --git a/aspnet-core/modules/account/LINGYUN.Abp.Account.Application/LINGYUN/Abp/Account/Emailing/IAccountEmailVerifySender.cs b/aspnet-core/modules/account/LINGYUN.Abp.Account.Emailing/LINGYUN/Abp/Account/Emailing/IAccountEmailVerifySender.cs similarity index 97% rename from aspnet-core/modules/account/LINGYUN.Abp.Account.Application/LINGYUN/Abp/Account/Emailing/IAccountEmailVerifySender.cs rename to aspnet-core/modules/account/LINGYUN.Abp.Account.Emailing/LINGYUN/Abp/Account/Emailing/IAccountEmailVerifySender.cs index 55eb373c0..10c898dbc 100644 --- a/aspnet-core/modules/account/LINGYUN.Abp.Account.Application/LINGYUN/Abp/Account/Emailing/IAccountEmailVerifySender.cs +++ b/aspnet-core/modules/account/LINGYUN.Abp.Account.Emailing/LINGYUN/Abp/Account/Emailing/IAccountEmailVerifySender.cs @@ -2,10 +2,10 @@ namespace LINGYUN.Abp.Account.Emailing; -public interface IAccountEmailVerifySender -{ - Task SendMailLoginVerifyCodeAsync( - string code, - string userName, - string emailAddress); +public interface IAccountEmailVerifySender +{ + Task SendMailLoginVerifyCodeAsync( + string code, + string userName, + string emailAddress); } diff --git a/aspnet-core/modules/account/LINGYUN.Abp.Account.Emailing/LINGYUN/Abp/Account/Emailing/Localization/AccountEmailingResource.cs b/aspnet-core/modules/account/LINGYUN.Abp.Account.Emailing/LINGYUN/Abp/Account/Emailing/Localization/AccountEmailingResource.cs new file mode 100644 index 000000000..a3b5dd5ef --- /dev/null +++ b/aspnet-core/modules/account/LINGYUN.Abp.Account.Emailing/LINGYUN/Abp/Account/Emailing/Localization/AccountEmailingResource.cs @@ -0,0 +1,8 @@ +using Volo.Abp.Localization; + +namespace LINGYUN.Abp.Account.Emailing.Localization; + +[LocalizationResourceName("AbpAccountEmailing")] +public class AccountEmailingResource +{ +} diff --git a/aspnet-core/modules/account/LINGYUN.Abp.Account.Templates/LINGYUN/Abp/Account/Templates/Localization/Resources/en.json b/aspnet-core/modules/account/LINGYUN.Abp.Account.Emailing/LINGYUN/Abp/Account/Emailing/Localization/Resources/en.json similarity index 100% rename from aspnet-core/modules/account/LINGYUN.Abp.Account.Templates/LINGYUN/Abp/Account/Templates/Localization/Resources/en.json rename to aspnet-core/modules/account/LINGYUN.Abp.Account.Emailing/LINGYUN/Abp/Account/Emailing/Localization/Resources/en.json diff --git a/aspnet-core/modules/account/LINGYUN.Abp.Account.Templates/LINGYUN/Abp/Account/Templates/Localization/Resources/zh-Hans.json b/aspnet-core/modules/account/LINGYUN.Abp.Account.Emailing/LINGYUN/Abp/Account/Emailing/Localization/Resources/zh-Hans.json similarity index 100% rename from aspnet-core/modules/account/LINGYUN.Abp.Account.Templates/LINGYUN/Abp/Account/Templates/Localization/Resources/zh-Hans.json rename to aspnet-core/modules/account/LINGYUN.Abp.Account.Emailing/LINGYUN/Abp/Account/Emailing/Localization/Resources/zh-Hans.json diff --git a/aspnet-core/modules/account/LINGYUN.Abp.Account.Emailing/LINGYUN/Abp/Account/Emailing/Templates/AccountEmailTemplates.cs b/aspnet-core/modules/account/LINGYUN.Abp.Account.Emailing/LINGYUN/Abp/Account/Emailing/Templates/AccountEmailTemplates.cs new file mode 100644 index 000000000..e033e7dcd --- /dev/null +++ b/aspnet-core/modules/account/LINGYUN.Abp.Account.Emailing/LINGYUN/Abp/Account/Emailing/Templates/AccountEmailTemplates.cs @@ -0,0 +1,13 @@ +namespace LINGYUN.Abp.Account.Emailing.Templates; + +public static class AccountEmailTemplates +{ + /// + /// 邮件地址确认 + /// + public const string MailConfirmLink = "Abp.Account.MailConfirmLink"; + /// + /// 邮件安全验证 + /// + public const string MailSecurityVerifyLink = "Abp.Account.MailSecurityVerifyLink"; +} diff --git a/aspnet-core/modules/account/LINGYUN.Abp.Account.Emailing/LINGYUN/Abp/Account/Emailing/Templates/AccountTemplateDefinitionProvider.cs b/aspnet-core/modules/account/LINGYUN.Abp.Account.Emailing/LINGYUN/Abp/Account/Emailing/Templates/AccountTemplateDefinitionProvider.cs new file mode 100644 index 000000000..b7b993696 --- /dev/null +++ b/aspnet-core/modules/account/LINGYUN.Abp.Account.Emailing/LINGYUN/Abp/Account/Emailing/Templates/AccountTemplateDefinitionProvider.cs @@ -0,0 +1,32 @@ +using LINGYUN.Abp.Account.Emailing.Localization; +using Volo.Abp.Emailing.Templates; +using Volo.Abp.Localization; +using Volo.Abp.TextTemplating; + +namespace LINGYUN.Abp.Account.Emailing.Templates; + +public class AccountTemplateDefinitionProvider : TemplateDefinitionProvider +{ + public override void Define(ITemplateDefinitionContext context) + { + context.Add( + new TemplateDefinition( + AccountEmailTemplates.MailSecurityVerifyLink, + displayName: L($"TextTemplate:{AccountEmailTemplates.MailSecurityVerifyLink}"), + layout: StandardEmailTemplates.Layout, + localizationResource: typeof(AccountEmailingResource) + ).WithVirtualFilePath("/LINGYUN/Abp/Account/Emailing/Templates/MailSecurityVerify.tpl", true), + new TemplateDefinition( + AccountEmailTemplates.MailConfirmLink, + displayName: L($"TextTemplate:{AccountEmailTemplates.MailConfirmLink}"), + layout: StandardEmailTemplates.Layout, + localizationResource: typeof(AccountEmailingResource) + ).WithVirtualFilePath("/LINGYUN/Abp/Account/Emailing/Templates/MailConfirm.tpl", true) + ); + } + + private static ILocalizableString L(string name) + { + return LocalizableString.Create(name); + } +} diff --git a/aspnet-core/modules/account/LINGYUN.Abp.Account.Emailing/LINGYUN/Abp/Account/Emailing/Templates/MailConfirm.tpl b/aspnet-core/modules/account/LINGYUN.Abp.Account.Emailing/LINGYUN/Abp/Account/Emailing/Templates/MailConfirm.tpl new file mode 100644 index 000000000..49bdcf0f8 --- /dev/null +++ b/aspnet-core/modules/account/LINGYUN.Abp.Account.Emailing/LINGYUN/Abp/Account/Emailing/Templates/MailConfirm.tpl @@ -0,0 +1,7 @@ +

{{L "EmailConfirm"}}

+ +

{{L "EmailConfirmInfo"}}

+ + \ No newline at end of file diff --git a/aspnet-core/modules/account/LINGYUN.Abp.Account.Emailing/LINGYUN/Abp/Account/Emailing/Templates/MailSecurityVerify.tpl b/aspnet-core/modules/account/LINGYUN.Abp.Account.Emailing/LINGYUN/Abp/Account/Emailing/Templates/MailSecurityVerify.tpl new file mode 100644 index 000000000..60a3bbf0a --- /dev/null +++ b/aspnet-core/modules/account/LINGYUN.Abp.Account.Emailing/LINGYUN/Abp/Account/Emailing/Templates/MailSecurityVerify.tpl @@ -0,0 +1,5 @@ +
+ {{L "VerifyMyEmailAddress"}}{{model.user}} +

{{model.code}}

+ {{L "MailSecurityVerifyRemarks"}} +
\ No newline at end of file diff --git a/aspnet-core/modules/account/LINGYUN.Abp.Account.Templates/LINGYUN.Abp.Account.Templates.csproj b/aspnet-core/modules/account/LINGYUN.Abp.Account.Templates/LINGYUN.Abp.Account.Templates.csproj index 4356d6e15..a6bb6fb13 100644 --- a/aspnet-core/modules/account/LINGYUN.Abp.Account.Templates/LINGYUN.Abp.Account.Templates.csproj +++ b/aspnet-core/modules/account/LINGYUN.Abp.Account.Templates/LINGYUN.Abp.Account.Templates.csproj @@ -15,12 +15,15 @@ - - + + + + + diff --git a/aspnet-core/modules/account/LINGYUN.Abp.Account.Templates/LINGYUN/Abp/Account/Templates/AbpAccountTemplatesModule.cs b/aspnet-core/modules/account/LINGYUN.Abp.Account.Templates/LINGYUN/Abp/Account/Emailing/AbpAccountEmailingModule.cs similarity index 67% rename from aspnet-core/modules/account/LINGYUN.Abp.Account.Templates/LINGYUN/Abp/Account/Templates/AbpAccountTemplatesModule.cs rename to aspnet-core/modules/account/LINGYUN.Abp.Account.Templates/LINGYUN/Abp/Account/Emailing/AbpAccountEmailingModule.cs index 5b4d97be5..dd6ca89b5 100644 --- a/aspnet-core/modules/account/LINGYUN.Abp.Account.Templates/LINGYUN/Abp/Account/Templates/AbpAccountTemplatesModule.cs +++ b/aspnet-core/modules/account/LINGYUN.Abp.Account.Templates/LINGYUN/Abp/Account/Emailing/AbpAccountEmailingModule.cs @@ -1,28 +1,28 @@ -using Volo.Abp.Account.Localization; -using Volo.Abp.Emailing; -using Volo.Abp.Localization; -using Volo.Abp.Modularity; -using Volo.Abp.VirtualFileSystem; - -namespace LINGYUN.Abp.Account.Templates; - -[DependsOn( - typeof(AbpEmailingModule), - typeof(AbpAccountApplicationContractsModule))] -public class AbpAccountTemplatesModule : AbpModule -{ - public override void ConfigureServices(ServiceConfigurationContext context) - { - Configure(options => - { - options.FileSets.AddEmbedded(); - }); - - Configure(options => - { - options.Resources - .Get() - .AddVirtualJson("/LINGYUN/Abp/Account/Templates/Localization/Resources"); - }); - } -} +using Volo.Abp.Account.Localization; +using Volo.Abp.Emailing; +using Volo.Abp.Localization; +using Volo.Abp.Modularity; +using Volo.Abp.VirtualFileSystem; + +namespace LINGYUN.Abp.Account.Emailing; + +[DependsOn( + typeof(AbpEmailingModule), + typeof(AbpAccountApplicationContractsModule))] +public class AbpAccountEmailingModule : AbpModule +{ + public override void ConfigureServices(ServiceConfigurationContext context) + { + Configure(options => + { + options.FileSets.AddEmbedded(); + }); + + Configure(options => + { + options.Resources + .Get() + .AddVirtualJson("/LINGYUN/Abp/Account/Emailing/Localization/Resources"); + }); + } +} diff --git a/aspnet-core/modules/account/LINGYUN.Abp.Account.Templates/LINGYUN/Abp/Account/Emailing/Localization/Resources/en.json b/aspnet-core/modules/account/LINGYUN.Abp.Account.Templates/LINGYUN/Abp/Account/Emailing/Localization/Resources/en.json new file mode 100644 index 000000000..ff2ebb3ca --- /dev/null +++ b/aspnet-core/modules/account/LINGYUN.Abp.Account.Templates/LINGYUN/Abp/Account/Emailing/Localization/Resources/en.json @@ -0,0 +1,16 @@ +{ + "culture": "en", + "texts": { + "TextTemplate:Abp.Account.MailSecurityVerifyLink": "Mail security validation template", + "TextTemplate:Abp.Account.MailConfirmLink": "Mail confirm template", + "MailSecurityVerify": "Mail security verification", + "VerifyMyEmailAddress": "Hello {0}

Your email security verification code is as follows. Please enter the verification code to proceed to the next step.

If not operated by you, please ignore this email.

", + "MailSecurityVerifyRemarks": "

(If it is not in the form of a link, copy the address to the browser address bar for further access)

Thank you for your visit and have a good time!

", + "ClickToValidation": "Click link verification", + "Validation": "Validation", + "EmailConfirm": "Email confirm", + "EmailConfirmInfo": "We received an email confirmation request! If you initiated this request, please click the link below to confirm the email address.", + "ConfirmMyEmail": "Bind my email address", + "YourEmailIsSuccessfullyConfirm": "Your email address was bound successfully." + } +} \ No newline at end of file diff --git a/aspnet-core/modules/account/LINGYUN.Abp.Account.Templates/LINGYUN/Abp/Account/Emailing/Localization/Resources/zh-Hans.json b/aspnet-core/modules/account/LINGYUN.Abp.Account.Templates/LINGYUN/Abp/Account/Emailing/Localization/Resources/zh-Hans.json new file mode 100644 index 000000000..bf4fe71f5 --- /dev/null +++ b/aspnet-core/modules/account/LINGYUN.Abp.Account.Templates/LINGYUN/Abp/Account/Emailing/Localization/Resources/zh-Hans.json @@ -0,0 +1,16 @@ +{ + "culture": "zh-Hans", + "texts": { + "TextTemplate:Abp.Account.MailSecurityVerifyLink": "邮件验证模板", + "TextTemplate:Abp.Account.MailConfirmLink": "邮件确认模板", + "MailSecurityVerify": "邮件安全验证", + "VerifyMyEmailAddress": "您好

您此次邮件安全验证码如下,请输入验证码进行下一步操作。

如非你本人操作,请忽略此邮件。

", + "MailSecurityVerifyRemarks": "此邮件为系统所发,请勿直接回复。", + "ClickToValidation": "点击进行验证", + "Validation": "验证", + "EmailConfirm": "邮件确认", + "EmailConfirmInfo": "我们收到了邮件确认请求!如果你发起了此请求,请单击以下链接以确认邮件地址.", + "ConfirmMyEmail": "绑定我的邮箱地址", + "YourEmailIsSuccessfullyConfirm": "您的邮件地址绑定成功." + } +} \ No newline at end of file diff --git a/aspnet-core/modules/account/LINGYUN.Abp.Account.Templates/LINGYUN/Abp/Account/Emailing/Templates/AccountEmailTemplates.cs b/aspnet-core/modules/account/LINGYUN.Abp.Account.Templates/LINGYUN/Abp/Account/Emailing/Templates/AccountEmailTemplates.cs index 4415d1452..44cedff32 100644 --- a/aspnet-core/modules/account/LINGYUN.Abp.Account.Templates/LINGYUN/Abp/Account/Emailing/Templates/AccountEmailTemplates.cs +++ b/aspnet-core/modules/account/LINGYUN.Abp.Account.Templates/LINGYUN/Abp/Account/Emailing/Templates/AccountEmailTemplates.cs @@ -1,13 +1,13 @@ -namespace LINGYUN.Abp.Account.Emailing.Templates; - +namespace LINGYUN.Abp.Account.Emailing.Templates; + public static class AccountEmailTemplates { - /// - /// 邮件地址确认 - /// + /// + /// 邮件地址确认 + /// public const string MailConfirmLink = "Abp.Account.MailConfirmLink"; - /// - /// 邮件安全验证 - /// + /// + /// 邮件安全验证 + /// public const string MailSecurityVerifyLink = "Abp.Account.MailSecurityVerifyLink"; -} +} diff --git a/aspnet-core/modules/account/LINGYUN.Abp.Account.Templates/LINGYUN/Abp/Account/Emailing/Templates/AccountTemplateDefinitionProvider.cs b/aspnet-core/modules/account/LINGYUN.Abp.Account.Templates/LINGYUN/Abp/Account/Emailing/Templates/AccountTemplateDefinitionProvider.cs index 265c8879b..d5d35b98d 100644 --- a/aspnet-core/modules/account/LINGYUN.Abp.Account.Templates/LINGYUN/Abp/Account/Emailing/Templates/AccountTemplateDefinitionProvider.cs +++ b/aspnet-core/modules/account/LINGYUN.Abp.Account.Templates/LINGYUN/Abp/Account/Emailing/Templates/AccountTemplateDefinitionProvider.cs @@ -1,10 +1,10 @@ using Volo.Abp.Account.Localization; -using Volo.Abp.Emailing.Templates; -using Volo.Abp.Localization; -using Volo.Abp.TextTemplating; - -namespace LINGYUN.Abp.Account.Emailing.Templates; - +using Volo.Abp.Emailing.Templates; +using Volo.Abp.Localization; +using Volo.Abp.TextTemplating; + +namespace LINGYUN.Abp.Account.Emailing.Templates; + public class AccountTemplateDefinitionProvider : TemplateDefinitionProvider { public override void Define(ITemplateDefinitionContext context) @@ -29,4 +29,4 @@ public class AccountTemplateDefinitionProvider : TemplateDefinitionProvider { return LocalizableString.Create(name); } -} +}