Browse Source

support email confirmation

pull/631/head
cKey 3 years ago
parent
commit
6de6fd0751
  1. 12
      aspnet-core/LINGYUN.MicroService.All.sln
  2. 8
      aspnet-core/modules/account/LINGYUN.Abp.Account.Application.Contracts/LINGYUN.Abp.Account.Application.Contracts.csproj
  3. 24
      aspnet-core/modules/account/LINGYUN.Abp.Account.Application.Contracts/LINGYUN/Abp/Account/AbpAccountApplicationContractsModule.cs
  4. 13
      aspnet-core/modules/account/LINGYUN.Abp.Account.Application.Contracts/LINGYUN/Abp/Account/Dto/ConfirmEmailInput.cs
  5. 21
      aspnet-core/modules/account/LINGYUN.Abp.Account.Application.Contracts/LINGYUN/Abp/Account/Dto/SendEmailConfirmCodeDto.cs
  6. 12
      aspnet-core/modules/account/LINGYUN.Abp.Account.Application.Contracts/LINGYUN/Abp/Account/IMyProfileAppService.cs
  7. 8
      aspnet-core/modules/account/LINGYUN.Abp.Account.Application.Contracts/LINGYUN/Abp/Account/Localization/Resources/en.json
  8. 8
      aspnet-core/modules/account/LINGYUN.Abp.Account.Application.Contracts/LINGYUN/Abp/Account/Localization/Resources/zh-Hans.json
  9. 5
      aspnet-core/modules/account/LINGYUN.Abp.Account.Application/LINGYUN.Abp.Account.Application.csproj
  10. 21
      aspnet-core/modules/account/LINGYUN.Abp.Account.Application/LINGYUN/Abp/Account/AbpAccountApplicationModule.cs
  11. 30
      aspnet-core/modules/account/LINGYUN.Abp.Account.Application/LINGYUN/Abp/Account/AccountAppService.cs
  12. 32
      aspnet-core/modules/account/LINGYUN.Abp.Account.Application/LINGYUN/Abp/Account/AccountSmsSecurityCodeSender.cs
  13. 6
      aspnet-core/modules/account/LINGYUN.Abp.Account.Application/LINGYUN/Abp/Account/AccountUrlNames.cs
  14. 92
      aspnet-core/modules/account/LINGYUN.Abp.Account.Application/LINGYUN/Abp/Account/Emailing/AccountEmailSender.cs
  15. 15
      aspnet-core/modules/account/LINGYUN.Abp.Account.Application/LINGYUN/Abp/Account/Emailing/IAccountEmailConfirmSender.cs
  16. 0
      aspnet-core/modules/account/LINGYUN.Abp.Account.Application/LINGYUN/Abp/Account/Emailing/IAccountEmailVerifySender.cs
  17. 14
      aspnet-core/modules/account/LINGYUN.Abp.Account.Application/LINGYUN/Abp/Account/IAccountSmsSecurityCodeSender.cs
  18. 64
      aspnet-core/modules/account/LINGYUN.Abp.Account.Application/LINGYUN/Abp/Account/MyProfileAppService.cs
  19. 28
      aspnet-core/modules/account/LINGYUN.Abp.Account.Domain.Shared/LINGYUN/Abp/Account/AbpAccountDomainSharedModule.cs
  20. 44
      aspnet-core/modules/account/LINGYUN.Abp.Account.Domain.Shared/LINGYUN/Abp/Account/Emailing/AccountEmailVerifySender.cs
  21. 22
      aspnet-core/modules/account/LINGYUN.Abp.Account.Domain.Shared/LINGYUN/Abp/Account/Emailing/Templates/AccountEmailTemplateDefinitionProvider.cs
  22. 8
      aspnet-core/modules/account/LINGYUN.Abp.Account.Domain.Shared/LINGYUN/Abp/Account/Localization/AbpAccountResource.cs
  23. 3
      aspnet-core/modules/account/LINGYUN.Abp.Account.Domain/FodyWeavers.xml
  24. 18
      aspnet-core/modules/account/LINGYUN.Abp.Account.Domain/LINGYUN.Abp.Account.Domain.csproj
  25. 9
      aspnet-core/modules/account/LINGYUN.Abp.Account.Domain/LINGYUN/Abp/Account/AbpAccountDomainModule.cs
  26. 16
      aspnet-core/modules/account/LINGYUN.Abp.Account.Domain/LINGYUN/Abp/Account/IIdentityUserRepository.cs
  27. 14
      aspnet-core/modules/account/LINGYUN.Abp.Account.HttpApi/LINGYUN/Abp/Account/AbpAccountHttpApiModule.cs
  28. 14
      aspnet-core/modules/account/LINGYUN.Abp.Account.HttpApi/LINGYUN/Abp/Account/MyProfileController.cs
  29. 0
      aspnet-core/modules/account/LINGYUN.Abp.Account.Templates/FodyWeavers.xml
  30. 0
      aspnet-core/modules/account/LINGYUN.Abp.Account.Templates/FodyWeavers.xsd
  31. 54
      aspnet-core/modules/account/LINGYUN.Abp.Account.Templates/LINGYUN.Abp.Account.Templates.csproj
  32. 6
      aspnet-core/modules/account/LINGYUN.Abp.Account.Templates/LINGYUN/Abp/Account/Emailing/Templates/AccountEmailTemplates.cs
  33. 32
      aspnet-core/modules/account/LINGYUN.Abp.Account.Templates/LINGYUN/Abp/Account/Emailing/Templates/AccountTemplateDefinitionProvider.cs
  34. 7
      aspnet-core/modules/account/LINGYUN.Abp.Account.Templates/LINGYUN/Abp/Account/Emailing/Templates/MailConfirm.tpl
  35. 0
      aspnet-core/modules/account/LINGYUN.Abp.Account.Templates/LINGYUN/Abp/Account/Emailing/Templates/MailSecurityVerify.tpl
  36. 13
      aspnet-core/modules/account/LINGYUN.Abp.Account.Templates/LINGYUN/Abp/Account/Templates/AbpAccountTemplatesModule.cs
  37. 16
      aspnet-core/modules/account/LINGYUN.Abp.Account.Templates/LINGYUN/Abp/Account/Templates/Localization/Resources/en.json
  38. 16
      aspnet-core/modules/account/LINGYUN.Abp.Account.Templates/LINGYUN/Abp/Account/Templates/Localization/Resources/zh-Hans.json
  39. 2
      aspnet-core/modules/cli/LINGYUN.Abp.Cli/LINGYUN.Abp.Cli.csproj
  40. 2
      aspnet-core/modules/identity/LINGYUN.Abp.Identity.Domain.Shared/LINGYUN.Abp.Identity.Domain.Shared.csproj
  41. 20
      aspnet-core/modules/identity/LINGYUN.Abp.Identity.Domain.Shared/LINGYUN/Abp/Identity/IUserSecurityCodeSender.cs
  42. 4
      aspnet-core/modules/identity/LINGYUN.Abp.Identity.Domain.Shared/LINGYUN/Abp/Identity/IdentityErrorCodes.cs
  43. 1
      aspnet-core/modules/identity/LINGYUN.Abp.Identity.Domain.Shared/LINGYUN/Abp/Identity/Localization/en.json
  44. 5
      aspnet-core/modules/identity/LINGYUN.Abp.Identity.Domain.Shared/LINGYUN/Abp/Identity/Localization/zh-Hans.json
  45. 2
      aspnet-core/modules/identity/LINGYUN.Abp.Identity.Domain.Shared/LINGYUN/Abp/Identity/Settings/IdentitySettingNames.cs
  46. 21
      aspnet-core/modules/identity/LINGYUN.Abp.Identity.Domain/LINGYUN/Abp/Identity/SecurityTokenCacheItem.cs
  47. 2
      aspnet-core/modules/platform/LINGYUN.Platform.Application.Contracts/LINGYUN/Platform/Menus/Dto/MenuCreateDto.cs
  48. 3
      aspnet-core/modules/platform/LINGYUN.Platform.Application.Contracts/LINGYUN/Platform/Menus/Dto/MenuCreateOrUpdateDto.cs
  49. 1
      aspnet-core/modules/platform/LINGYUN.Platform.Application/LINGYUN/Platform/Menus/MenuAppService.cs
  50. 6
      aspnet-core/modules/task-management/LINGYUN.Abp.BackgroundTasks.ExceptionHandling/LINGYUN/Abp/BackgroundTasks/ExceptionHandling/JobExecutedFailedProvider.cs
  51. 5
      aspnet-core/services/LY.MicroService.identityServer.HttpApi.Host/Emailing/Templates/EmailConfirmed.tpl
  52. 26
      aspnet-core/services/LY.MicroService.identityServer.HttpApi.Host/Emailing/Templates/IdentityEmailTemplateDefinitionProvider.cs
  53. 7
      aspnet-core/services/LY.MicroService.identityServer.HttpApi.Host/Emailing/Templates/IdentityEmailTemplates.cs
  54. 5
      aspnet-core/services/LY.MicroService.identityServer.HttpApi.Host/LY.MicroService.identityServer.HttpApi.Host.csproj
  55. 65
      aspnet-core/services/LY.MicroService.identityServer.HttpApi.Host/UserSecurityCodeSender.cs
  56. 6
      aspnet-core/services/LY.MicroService.identityServer/IdentityServerModule.Configure.cs
  57. 2
      aspnet-core/services/LY.MicroService.identityServer/IdentityServerModule.cs
  58. 2
      aspnet-core/services/LY.MicroService.identityServer/LY.MicroService.IdentityServer.csproj
  59. 56
      aspnet-core/services/LY.MicroService.identityServer/Pages/Account/Components/ProfileManagementGroup/PersonalInfo/Default.cshtml
  60. 28
      aspnet-core/services/LY.MicroService.identityServer/Pages/Account/Components/ProfileManagementGroup/PersonalInfo/Default.js
  61. 17
      aspnet-core/services/LY.MicroService.identityServer/Pages/Account/EmailConfirm.cshtml
  62. 75
      aspnet-core/services/LY.MicroService.identityServer/Pages/Account/EmailConfirm.cshtml.cs
  63. 13
      aspnet-core/services/LY.MicroService.identityServer/Pages/Account/EmailConfirmConfirmation.cshtml
  64. 23
      aspnet-core/services/LY.MicroService.identityServer/Pages/Account/EmailConfirmConfirmation.cshtml.cs
  65. 16
      aspnet-core/services/LY.MicroService.identityServer/Pages/Account/SendEmailConfirm.cshtml
  66. 75
      aspnet-core/services/LY.MicroService.identityServer/Pages/Account/SendEmailConfirm.cshtml.cs
  67. 1
      aspnet-core/services/LY.MicroService.identityServer/appsettings.Development.json
  68. 1
      build/modules.dependencies.json

12
aspnet-core/LINGYUN.MicroService.All.sln

@ -428,7 +428,7 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LINGYUN.Abp.Notifications.C
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LINGYUN.Abp.AspNetCore.Mvc.Localization", "modules\localization\LINGYUN.Abp.AspNetCore.Mvc.Localization\LINGYUN.Abp.AspNetCore.Mvc.Localization.csproj", "{995DB1CE-A2FC-4468-A521-4207FD587EC5}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LINGYUN.Abp.Account.Domain.Shared", "modules\account\LINGYUN.Abp.Account.Domain.Shared\LINGYUN.Abp.Account.Domain.Shared.csproj", "{446852ED-D80C-450F-8383-6B1ADCA08A59}"
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LINGYUN.Abp.Account.Templates", "modules\account\LINGYUN.Abp.Account.Templates\LINGYUN.Abp.Account.Templates.csproj", "{AFFBE8EE-1B92-4CDF-8A4F-4000B78A0154}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
@ -1112,10 +1112,10 @@ Global
{995DB1CE-A2FC-4468-A521-4207FD587EC5}.Debug|Any CPU.Build.0 = Debug|Any CPU
{995DB1CE-A2FC-4468-A521-4207FD587EC5}.Release|Any CPU.ActiveCfg = Release|Any CPU
{995DB1CE-A2FC-4468-A521-4207FD587EC5}.Release|Any CPU.Build.0 = Release|Any CPU
{446852ED-D80C-450F-8383-6B1ADCA08A59}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{446852ED-D80C-450F-8383-6B1ADCA08A59}.Debug|Any CPU.Build.0 = Debug|Any CPU
{446852ED-D80C-450F-8383-6B1ADCA08A59}.Release|Any CPU.ActiveCfg = Release|Any CPU
{446852ED-D80C-450F-8383-6B1ADCA08A59}.Release|Any CPU.Build.0 = Release|Any CPU
{AFFBE8EE-1B92-4CDF-8A4F-4000B78A0154}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{AFFBE8EE-1B92-4CDF-8A4F-4000B78A0154}.Debug|Any CPU.Build.0 = Debug|Any CPU
{AFFBE8EE-1B92-4CDF-8A4F-4000B78A0154}.Release|Any CPU.ActiveCfg = Release|Any CPU
{AFFBE8EE-1B92-4CDF-8A4F-4000B78A0154}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
@ -1325,7 +1325,7 @@ Global
{A53FE09E-6B1C-46C0-9422-C313D14AE9E4} = {ABD89F39-62D9-439E-8662-BE4F36BFA04F}
{0CE035CF-2D8A-4559-93EC-ADBEC4237C61} = {8AC72641-30D3-4ACF-89FA-808FADC55C2E}
{995DB1CE-A2FC-4468-A521-4207FD587EC5} = {90E88EAC-4291-4406-8D88-EFDF61B11292}
{446852ED-D80C-450F-8383-6B1ADCA08A59} = {9E72FEB9-A626-4312-892B-CDD043879758}
{AFFBE8EE-1B92-4CDF-8A4F-4000B78A0154} = {9E72FEB9-A626-4312-892B-CDD043879758}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {C95FDF91-16F2-4A8B-A4BE-0E62D1B66718}

8
aspnet-core/modules/account/LINGYUN.Abp.Account.Application.Contracts/LINGYUN.Abp.Account.Application.Contracts.csproj

@ -9,11 +9,15 @@
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Volo.Abp.Account.Application.Contracts" Version="$(VoloAbpPackageVersion)" />
<None Remove="LINGYUN\Abp\Account\Localization\Resources\*.json" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\LINGYUN.Abp.Account.Domain.Shared\LINGYUN.Abp.Account.Domain.Shared.csproj" />
<EmbeddedResource Include="LINGYUN\Abp\Account\Localization\Resources\*.json" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Volo.Abp.Account.Application.Contracts" Version="$(VoloAbpPackageVersion)" />
</ItemGroup>
</Project>

24
aspnet-core/modules/account/LINGYUN.Abp.Account.Application.Contracts/LINGYUN/Abp/Account/AbpAccountApplicationContractsModule.cs

@ -1,11 +1,27 @@
using Volo.Abp.Modularity;
using Volo.Abp.Account.Localization;
using Volo.Abp.Localization;
using Volo.Abp.Modularity;
using Volo.Abp.VirtualFileSystem;
namespace LINGYUN.Abp.Account
{
[DependsOn(
typeof(Volo.Abp.Account.AbpAccountApplicationContractsModule),
typeof(AbpAccountDomainSharedModule))]
typeof(Volo.Abp.Account.AbpAccountApplicationContractsModule))]
public class AbpAccountApplicationContractsModule : AbpModule
{
public override void ConfigureServices(ServiceConfigurationContext context)
{
Configure<AbpVirtualFileSystemOptions>(options =>
{
options.FileSets.AddEmbedded<AbpAccountApplicationContractsModule>();
});
Configure<AbpLocalizationOptions>(options =>
{
options.Resources
.Get<AccountResource>()
.AddVirtualJson("/LINGYUN/Abp/Account/Localization/Resources");
});
}
}
}

13
aspnet-core/modules/account/LINGYUN.Abp.Account.Application.Contracts/LINGYUN/Abp/Account/Dto/ConfirmEmailInput.cs

@ -0,0 +1,13 @@
using System;
using System.ComponentModel.DataAnnotations;
namespace LINGYUN.Abp.Account;
public class ConfirmEmailInput
{
[Required]
public Guid UserId { get; set; }
[Required]
public string ConfirmToken { get; set; }
}

21
aspnet-core/modules/account/LINGYUN.Abp.Account.Application.Contracts/LINGYUN/Abp/Account/Dto/SendEmailConfirmCodeDto.cs

@ -0,0 +1,21 @@
using System.ComponentModel.DataAnnotations;
using Volo.Abp.Identity;
using Volo.Abp.Validation;
namespace LINGYUN.Abp.Account;
public class SendEmailConfirmCodeDto
{
[Required]
[EmailAddress]
[Display(Name = "EmailAddress")]
[DynamicStringLength(typeof(IdentityUserConsts), nameof(IdentityUserConsts.MaxEmailLength))]
public string Email { get; set; }
[Required]
public string AppName { get; set; }
public string ReturnUrl { get; set; }
public string ReturnUrlHash { get; set; }
}

12
aspnet-core/modules/account/LINGYUN.Abp.Account.Application.Contracts/LINGYUN/Abp/Account/IMyProfileAppService.cs

@ -31,5 +31,17 @@ namespace LINGYUN.Abp.Account
/// 需二次认证,主要是为了无法用到重定向页面修改相关信息的地方(点名微信小程序)
/// </remarks>
Task ChangePhoneNumberAsync(ChangePhoneNumberInput input);
/// <summary>
/// 发送确认邮件验证码
/// </summary>
/// <param name="input"></param>
/// <returns></returns>
Task SendEmailConfirmLinkAsync(SendEmailConfirmCodeDto input);
/// <summary>
/// 确认邮件地址
/// </summary>
/// <param name="input"></param>
/// <returns></returns>
Task ConfirmEmailAsync(ConfirmEmailInput input);
}
}

8
aspnet-core/modules/account/LINGYUN.Abp.Account.Domain.Shared/LINGYUN/Abp/Account/Localization/Resources/en.json → aspnet-core/modules/account/LINGYUN.Abp.Account.Application.Contracts/LINGYUN/Abp/Account/Localization/Resources/en.json

@ -4,6 +4,7 @@
"UserNotRegisterd": "The user account is not registered!",
"UserEmailNotConfirmed": "The user's email address is not confirmed!",
"SendRepeatSmsVerifyCode": "Phone verification code cannot be sent repeatedly within {0} minutes!",
"SendRepeatEmailVerifyCode": "Email verification code cannot be sent repeatedly within {0} minutes!",
"DuplicatePhoneNumber": "The phone number already exists!",
"PhoneNumberNotRegisterd": "The registered mobile phone number is not registered!",
"InvalidVerifyCode": "The verification code is invalid or expired!",
@ -24,11 +25,6 @@
"VerifyAuthenticatorCode": "Authentication code",
"RememberBrowser": "Remember me in the browser",
"TwoFactorAuthenticationInvaidUser": "Authentication failed. Your session is invalid. Please re login try again!",
"InvaidGenerateTwoFactorToken": "Verification code generation failed. Please contact your administrator!",
"TextTemplate:Abp.Account.MailSecurityVerifyLink": "Mail security validation template",
"MailSecurityVerify": "Mail security verification",
"VerifyMyEmailAddress": "Hello {0}<br/><p>Your email security verification code is as follows. Please enter the verification code to proceed to the next step.</p><p>If not operated by you, please ignore this email.</p>",
"MailSecurityVerifyRemarks": "<p>(If it is not in the form of a link, copy the address to the browser address bar for further access)</p><p>Thank you for your visit and have a good time!</p>",
"ClickToValidation": "Click link verification"
"InvaidGenerateTwoFactorToken": "Verification code generation failed. Please contact your administrator!"
}
}

8
aspnet-core/modules/account/LINGYUN.Abp.Account.Domain.Shared/LINGYUN/Abp/Account/Localization/Resources/zh-Hans.json → aspnet-core/modules/account/LINGYUN.Abp.Account.Application.Contracts/LINGYUN/Abp/Account/Localization/Resources/zh-Hans.json

@ -4,6 +4,7 @@
"UserNotRegisterd": "用户账号未注册!",
"UserEmailNotConfirmed": "用户邮件地址未确认!",
"SendRepeatSmsVerifyCode": "手机验证码不能在 {0} 分钟内重复发送!",
"SendRepeatEmailVerifyCode": "邮件验证码不能在 {0} 分钟内重复发送!",
"DuplicatePhoneNumber": "手机号已经存在!",
"PhoneNumberNotRegisterd": "手机号码未注册!",
"InvalidVerifyCode": "验证码无效或已经过期!",
@ -24,11 +25,6 @@
"VerifyAuthenticatorCode": "验证身份代码",
"RememberBrowser": "在浏览器中记住我",
"TwoFactorAuthenticationInvaidUser": "认证失败,您的会话已失效,请程序登录!",
"InvaidGenerateTwoFactorToken": "验证码生成失败,请联系管理员!",
"TextTemplate:Abp.Account.MailSecurityVerifyLink": "邮件安全验证模板",
"MailSecurityVerify": "邮件安全验证",
"VerifyMyEmailAddress": "您好<br/><p>您此次邮件安全验证码如下,请输入验证码进行下一步操作。</p><p>如非你本人操作,请忽略此邮件。</p>",
"MailSecurityVerifyRemarks": "此邮件为系统所发,请勿直接回复。",
"ClickToValidation": "点击进行验证"
"InvaidGenerateTwoFactorToken": "验证码生成失败,请联系管理员!"
}
}

5
aspnet-core/modules/account/LINGYUN.Abp.Account.Application/LINGYUN.Abp.Account.Application.csproj

@ -18,6 +18,11 @@
<ProjectReference Include="..\..\identity\LINGYUN.Abp.Identity.Domain\LINGYUN.Abp.Identity.Domain.csproj" />
<ProjectReference Include="..\..\wechat\LINGYUN.Abp.WeChat.MiniProgram\LINGYUN.Abp.WeChat.MiniProgram.csproj" />
<ProjectReference Include="..\LINGYUN.Abp.Account.Application.Contracts\LINGYUN.Abp.Account.Application.Contracts.csproj" />
<ProjectReference Include="..\LINGYUN.Abp.Account.Templates\LINGYUN.Abp.Account.Templates.csproj" />
</ItemGroup>
<ItemGroup>
<Folder Include="LINGYUN\Abp\Account\Emailing\" />
</ItemGroup>
</Project>

21
aspnet-core/modules/account/LINGYUN.Abp.Account.Application/LINGYUN/Abp/Account/AbpAccountApplicationModule.cs

@ -1,16 +1,31 @@
using LINGYUN.Abp.Identity;
using LINGYUN.Abp.Account.Templates;
using LINGYUN.Abp.Identity;
using LINGYUN.Abp.WeChat.MiniProgram;
using Volo.Abp.Modularity;
using Volo.Abp.UI.Navigation.Urls;
using Volo.Abp.VirtualFileSystem;
namespace LINGYUN.Abp.Account
{
[DependsOn(
typeof(Volo.Abp.Account.AbpAccountApplicationModule),
typeof(AbpAccountApplicationContractsModule),
typeof(AbpAccountTemplatesModule),
typeof(AbpIdentityDomainModule),
typeof(AbpWeChatMiniProgramModule))]
public class AbpAccountApplicationModule : AbpModule
{
public override void ConfigureServices(ServiceConfigurationContext context)
{
Configure<AbpVirtualFileSystemOptions>(options =>
{
options.FileSets.AddEmbedded<AbpAccountApplicationModule>();
});
Configure<AppUrlOptions>(options =>
{
options.Applications["MVC"].Urls[AccountUrlNames.EmailConfirm] = "Account/EmailConfirm";
});
}
}
}

30
aspnet-core/modules/account/LINGYUN.Abp.Account.Application/LINGYUN/Abp/Account/AccountAppService.cs

@ -30,18 +30,18 @@ namespace LINGYUN.Abp.Account
{
protected ITotpService TotpService { get; }
protected IIdentityUserRepository UserRepository { get; }
protected IUserSecurityCodeSender SecurityCodeSender { get; }
protected IAccountSmsSecurityCodeSender SecurityCodeSender { get; }
protected IWeChatOpenIdFinder WeChatOpenIdFinder { get; }
protected IdentitySecurityLogManager IdentitySecurityLogManager { get; }
protected AbpWeChatMiniProgramOptionsFactory MiniProgramOptionsFactory { get; }
protected IDistributedCache<SmsSecurityTokenCacheItem> SecurityTokenCache { get; }
protected IDistributedCache<SecurityTokenCacheItem> SecurityTokenCache { get; }
public AccountAppService(
ITotpService totpService,
IWeChatOpenIdFinder weChatOpenIdFinder,
IIdentityUserRepository userRepository,
IUserSecurityCodeSender securityCodeSender,
IDistributedCache<SmsSecurityTokenCacheItem> securityTokenCache,
IAccountSmsSecurityCodeSender securityCodeSender,
IDistributedCache<SecurityTokenCacheItem> securityTokenCache,
AbpWeChatMiniProgramOptionsFactory miniProgramOptionsFactory,
IdentitySecurityLogManager identitySecurityLogManager)
{
@ -108,7 +108,7 @@ namespace LINGYUN.Abp.Account
await CheckSelfRegistrationAsync();
await CheckNewUserPhoneNumberNotBeUsedAsync(input.PhoneNumber);
var securityTokenCacheKey = SmsSecurityTokenCacheItem.CalculateCacheKey(input.PhoneNumber, "SmsVerifyCode");
var securityTokenCacheKey = SecurityTokenCacheItem.CalculateSmsCacheKey(input.PhoneNumber, "SmsVerifyCode");
var securityTokenCacheItem = await SecurityTokenCache.GetAsync(securityTokenCacheKey);
var interval = await SettingProvider.GetAsync(IdentitySettingNames.User.SmsRepetInterval, 1);
@ -123,9 +123,9 @@ namespace LINGYUN.Abp.Account
var securityToken = GuidGenerator.Create().ToString("N");
var code = TotpService.GenerateCode(Encoding.Unicode.GetBytes(securityToken), securityTokenCacheKey);
securityTokenCacheItem = new SmsSecurityTokenCacheItem(code.ToString(), securityToken);
securityTokenCacheItem = new SecurityTokenCacheItem(code.ToString(), securityToken);
await SecurityCodeSender.SendPhoneConfirmedCodeAsync(
await SecurityCodeSender.SendSmsCodeAsync(
input.PhoneNumber, securityTokenCacheItem.Token, template);
await SecurityTokenCache
@ -142,7 +142,7 @@ namespace LINGYUN.Abp.Account
await IdentityOptions.SetAsync();
await CheckNewUserPhoneNumberNotBeUsedAsync(input.PhoneNumber);
var securityTokenCacheKey = SmsSecurityTokenCacheItem.CalculateCacheKey(input.PhoneNumber, "SmsVerifyCode");
var securityTokenCacheKey = SecurityTokenCacheItem.CalculateSmsCacheKey(input.PhoneNumber, "SmsVerifyCode");
var securityTokenCacheItem = await SecurityTokenCache.GetAsync(securityTokenCacheKey);
if (securityTokenCacheItem == null)
{
@ -216,7 +216,7 @@ namespace LINGYUN.Abp.Account
throw new BusinessException(code: Volo.Abp.Identity.IdentityErrorCodes.ExternalUserPasswordChange);
}
var securityTokenCacheKey = SmsSecurityTokenCacheItem.CalculateCacheKey(input.PhoneNumber, "SmsVerifyCode");
var securityTokenCacheKey = SecurityTokenCacheItem.CalculateSmsCacheKey(input.PhoneNumber, "SmsVerifyCode");
var securityTokenCacheItem = await SecurityTokenCache.GetAsync(securityTokenCacheKey);
var interval = await SettingProvider.GetAsync(IdentitySettingNames.User.SmsRepetInterval, 1);
// 能查询到缓存就是重复发送
@ -229,9 +229,9 @@ namespace LINGYUN.Abp.Account
// 生成二次认证码
var code = await UserManager.GenerateTwoFactorTokenAsync(user, TokenOptions.DefaultPhoneProvider);
// 发送短信验证码
await SecurityCodeSender.SendPhoneConfirmedCodeAsync(input.PhoneNumber, code, template);
await SecurityCodeSender.SendSmsCodeAsync(input.PhoneNumber, code, template);
// 缓存这个手机号的记录,防重复
securityTokenCacheItem = new SmsSecurityTokenCacheItem(code, user.SecurityStamp);
securityTokenCacheItem = new SecurityTokenCacheItem(code, user.SecurityStamp);
await SecurityTokenCache
.SetAsync(securityTokenCacheKey, securityTokenCacheItem,
new DistributedCacheEntryOptions
@ -242,7 +242,7 @@ namespace LINGYUN.Abp.Account
public virtual async Task ResetPasswordAsync(PhoneResetPasswordDto input)
{
var securityTokenCacheKey = SmsSecurityTokenCacheItem.CalculateCacheKey(input.PhoneNumber, "SmsVerifyCode");
var securityTokenCacheKey = SecurityTokenCacheItem.CalculateSmsCacheKey(input.PhoneNumber, "SmsVerifyCode");
var securityTokenCacheItem = await SecurityTokenCache.GetAsync(securityTokenCacheKey);
if (securityTokenCacheItem == null)
{
@ -283,7 +283,7 @@ namespace LINGYUN.Abp.Account
public virtual async Task SendPhoneSigninCodeAsync(SendPhoneSigninCodeDto input)
{
var securityTokenCacheKey = SmsSecurityTokenCacheItem.CalculateCacheKey(input.PhoneNumber, "SmsVerifyCode");
var securityTokenCacheKey = SecurityTokenCacheItem.CalculateSmsCacheKey(input.PhoneNumber, "SmsVerifyCode");
var securityTokenCacheItem = await SecurityTokenCache.GetAsync(securityTokenCacheKey);
var interval = await SettingProvider.GetAsync(IdentitySettingNames.User.SmsRepetInterval, 1);
if (securityTokenCacheItem != null)
@ -296,9 +296,9 @@ namespace LINGYUN.Abp.Account
var template = await SettingProvider.GetOrNullAsync(IdentitySettingNames.User.SmsUserSignin);
// 发送登录验证码短信
await SecurityCodeSender.SendPhoneConfirmedCodeAsync(input.PhoneNumber, code, template);
await SecurityCodeSender.SendSmsCodeAsync(input.PhoneNumber, code, template);
// 缓存登录验证码状态,防止同一手机号重复发送
securityTokenCacheItem = new SmsSecurityTokenCacheItem(code, user.SecurityStamp);
securityTokenCacheItem = new SecurityTokenCacheItem(code, user.SecurityStamp);
await SecurityTokenCache
.SetAsync(securityTokenCacheKey, securityTokenCacheItem,
new DistributedCacheEntryOptions

32
aspnet-core/modules/account/LINGYUN.Abp.Account.Application/LINGYUN/Abp/Account/AccountSmsSecurityCodeSender.cs

@ -0,0 +1,32 @@
using System.Threading;
using System.Threading.Tasks;
using Volo.Abp;
using Volo.Abp.DependencyInjection;
using Volo.Abp.Sms;
namespace LINGYUN.Abp.Account;
public class AccountSmsSecurityCodeSender : IAccountSmsSecurityCodeSender, ITransientDependency
{
protected ISmsSender SmsSender { get; }
public AccountSmsSecurityCodeSender(ISmsSender smsSender)
{
SmsSender = smsSender;
}
public async virtual Task SendSmsCodeAsync(
string phone,
string token,
string template,
CancellationToken cancellation = default)
{
Check.NotNullOrWhiteSpace(template, nameof(template));
var smsMessage = new SmsMessage(phone, token);
smsMessage.Properties.Add("code", token);
smsMessage.Properties.Add("TemplateCode", template);
await SmsSender.SendAsync(smsMessage);
}
}

6
aspnet-core/modules/account/LINGYUN.Abp.Account.Application/LINGYUN/Abp/Account/AccountUrlNames.cs

@ -0,0 +1,6 @@
namespace LINGYUN.Abp.Account;
public static class AccountUrlNames
{
public const string EmailConfirm = "Abp.Account.EmailConfirm";
}

92
aspnet-core/modules/account/LINGYUN.Abp.Account.Application/LINGYUN/Abp/Account/Emailing/AccountEmailSender.cs

@ -0,0 +1,92 @@
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<AccountResource> 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={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(
user.Email,
StringLocalizer["EmailConfirm"],
emailContent
);
}
}

15
aspnet-core/modules/account/LINGYUN.Abp.Account.Application/LINGYUN/Abp/Account/Emailing/IAccountEmailConfirmSender.cs

@ -0,0 +1,15 @@
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
);
}

0
aspnet-core/modules/account/LINGYUN.Abp.Account.Domain.Shared/LINGYUN/Abp/Account/Emailing/IAccountEmailVerifySender.cs → aspnet-core/modules/account/LINGYUN.Abp.Account.Application/LINGYUN/Abp/Account/Emailing/IAccountEmailVerifySender.cs

14
aspnet-core/modules/account/LINGYUN.Abp.Account.Application/LINGYUN/Abp/Account/IAccountSmsSecurityCodeSender.cs

@ -0,0 +1,14 @@
using System.Threading;
using System.Threading.Tasks;
namespace LINGYUN.Abp.Account
{
public interface IAccountSmsSecurityCodeSender
{
Task SendSmsCodeAsync(
string phone,
string token,
string template, // 传递模板号
CancellationToken cancellation = default);
}
}

64
aspnet-core/modules/account/LINGYUN.Abp.Account.Application/LINGYUN/Abp/Account/MyProfileAppService.cs

@ -1,12 +1,15 @@
using LINGYUN.Abp.Identity;
using LINGYUN.Abp.Account.Emailing;
using LINGYUN.Abp.Identity;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Identity;
using Microsoft.Extensions.Caching.Distributed;
using Microsoft.Extensions.Options;
using System;
using System.Threading.Tasks;
using Volo.Abp;
using Volo.Abp.Account.Localization;
using Volo.Abp.Caching;
using Volo.Abp.Identity;
using Volo.Abp.Settings;
namespace LINGYUN.Abp.Account
@ -14,17 +17,20 @@ namespace LINGYUN.Abp.Account
[Authorize]
public class MyProfileAppService : AccountApplicationServiceBase, IMyProfileAppService
{
protected IDistributedCache<SmsSecurityTokenCacheItem> SecurityTokenCache { get; }
protected IUserSecurityCodeSender SecurityCodeSender { get; }
protected IDistributedCache<SecurityTokenCacheItem> SecurityTokenCache { get; }
protected IAccountSmsSecurityCodeSender SecurityCodeSender { get; }
protected Identity.IIdentityUserRepository UserRepository { get; }
protected IdentitySecurityLogManager IdentitySecurityLogManager { get; }
public MyProfileAppService(
Identity.IIdentityUserRepository userRepository,
IUserSecurityCodeSender securityCodeSender,
IDistributedCache<SmsSecurityTokenCacheItem> securityTokenCache)
IAccountSmsSecurityCodeSender securityCodeSender,
IdentitySecurityLogManager identitySecurityLogManager,
IDistributedCache<SecurityTokenCacheItem> securityTokenCache)
{
UserRepository = userRepository;
SecurityCodeSender = securityCodeSender;
IdentitySecurityLogManager = identitySecurityLogManager;
SecurityTokenCache = securityTokenCache;
LocalizationResource = typeof(AccountResource);
@ -57,7 +63,7 @@ namespace LINGYUN.Abp.Account
public virtual async Task SendChangePhoneNumberCodeAsync(SendChangePhoneNumberCodeInput input)
{
var securityTokenCacheKey = SmsSecurityTokenCacheItem.CalculateCacheKey(input.NewPhoneNumber, "SmsChangePhoneNumber");
var securityTokenCacheKey = SecurityTokenCacheItem.CalculateSmsCacheKey(input.NewPhoneNumber, "SmsChangePhoneNumber");
var securityTokenCacheItem = await SecurityTokenCache.GetAsync(securityTokenCacheKey);
var interval = await SettingProvider.GetAsync(Identity.Settings.IdentitySettingNames.User.SmsRepetInterval, 1);
if (securityTokenCacheItem != null)
@ -75,9 +81,9 @@ namespace LINGYUN.Abp.Account
var template = await SettingProvider.GetOrNullAsync(Identity.Settings.IdentitySettingNames.User.SmsPhoneNumberConfirmed);
var token = await UserManager.GenerateChangePhoneNumberTokenAsync(user, input.NewPhoneNumber);
// 发送验证码
await SecurityCodeSender.SendPhoneConfirmedCodeAsync(input.NewPhoneNumber, token, template);
await SecurityCodeSender.SendSmsCodeAsync(input.NewPhoneNumber, token, template);
securityTokenCacheItem = new SmsSecurityTokenCacheItem(token, user.ConcurrencyStamp);
securityTokenCacheItem = new SecurityTokenCacheItem(token, user.ConcurrencyStamp);
await SecurityTokenCache
.SetAsync(securityTokenCacheKey, securityTokenCacheItem,
new DistributedCacheEntryOptions
@ -99,8 +105,48 @@ namespace LINGYUN.Abp.Account
await CurrentUnitOfWork.SaveChangesAsync();
var securityTokenCacheKey = SmsSecurityTokenCacheItem.CalculateCacheKey(input.NewPhoneNumber, "SmsChangePhoneNumber");
var securityTokenCacheKey = SecurityTokenCacheItem.CalculateSmsCacheKey(input.NewPhoneNumber, "SmsChangePhoneNumber");
await SecurityTokenCache.RemoveAsync(securityTokenCacheKey);
}
public async virtual Task SendEmailConfirmLinkAsync(SendEmailConfirmCodeDto input)
{
var user = await UserManager.FindByEmailAsync(input.Email);
if (user == null)
{
throw new UserFriendlyException(L["Volo.Account:InvalidEmailAddress", input.Email]);
}
if (user.EmailConfirmed)
{
throw new BusinessException(Identity.IdentityErrorCodes.DuplicateConfirmEmailAddress);
}
var token = await UserManager.GenerateEmailConfirmationTokenAsync(user);
var sender = LazyServiceProvider.LazyGetRequiredService<IAccountEmailConfirmSender>();
await sender.SendEmailConfirmLinkAsync(
user,
token,
input.AppName,
input.ReturnUrl,
input.ReturnUrlHash);
}
public async virtual Task ConfirmEmailAsync(ConfirmEmailInput input)
{
await IdentityOptions.SetAsync();
var user = await UserManager.GetByIdAsync(input.UserId);
(await UserManager.ConfirmEmailAsync(user, input.ConfirmToken)).CheckErrors();
await IdentitySecurityLogManager.SaveAsync(new IdentitySecurityLogContext
{
Identity = IdentitySecurityLogIdentityConsts.Identity,
Action = "ConfirmEmail"
});
}
}
}

28
aspnet-core/modules/account/LINGYUN.Abp.Account.Domain.Shared/LINGYUN/Abp/Account/AbpAccountDomainSharedModule.cs

@ -1,28 +0,0 @@
using LINGYUN.Abp.Account.Localization;
using Volo.Abp.Emailing;
using Volo.Abp.Localization;
using Volo.Abp.Modularity;
using Volo.Abp.VirtualFileSystem;
namespace LINGYUN.Abp.Account
{
[DependsOn(
typeof(AbpEmailingModule))]
public class AbpAccountDomainSharedModule : AbpModule
{
public override void ConfigureServices(ServiceConfigurationContext context)
{
Configure<AbpVirtualFileSystemOptions>(options =>
{
options.FileSets.AddEmbedded<AbpAccountDomainSharedModule>();
});
Configure<AbpLocalizationOptions>(options =>
{
options.Resources
.Add<AbpAccountResource>("en")
.AddVirtualJson("/LINGYUN/Abp/Account/Localization/Resources");
});
}
}
}

44
aspnet-core/modules/account/LINGYUN.Abp.Account.Domain.Shared/LINGYUN/Abp/Account/Emailing/AccountEmailVerifySender.cs

@ -1,44 +0,0 @@
using LINGYUN.Abp.Account.Localization;
using LY.MicroService.IdentityServer.Emailing.Templates;
using Microsoft.Extensions.Localization;
using System.Threading.Tasks;
using Volo.Abp.DependencyInjection;
using Volo.Abp.Emailing;
using Volo.Abp.TextTemplating;
namespace LINGYUN.Abp.Account.Emailing;
public class AccountEmailVerifySender : IAccountEmailVerifySender, ITransientDependency
{
protected IEmailSender EmailSender { get; }
protected ITemplateRenderer TemplateRenderer { get; }
protected IStringLocalizer<AbpAccountResource> StringLocalizer { get; }
public AccountEmailVerifySender(
IEmailSender emailSender,
ITemplateRenderer templateRenderer,
IStringLocalizer<AbpAccountResource> stringLocalizer)
{
EmailSender = emailSender;
TemplateRenderer = templateRenderer;
StringLocalizer = stringLocalizer;
}
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
);
}
}

22
aspnet-core/modules/account/LINGYUN.Abp.Account.Domain.Shared/LINGYUN/Abp/Account/Emailing/Templates/AccountEmailTemplateDefinitionProvider.cs

@ -1,22 +0,0 @@
using LINGYUN.Abp.Account.Localization;
using Volo.Abp.Emailing.Templates;
using Volo.Abp.Localization;
using Volo.Abp.TextTemplating;
namespace LY.MicroService.IdentityServer.Emailing.Templates;
public class AccountEmailTemplateDefinitionProvider : TemplateDefinitionProvider
{
public override void Define(ITemplateDefinitionContext context)
{
context.Add(
new TemplateDefinition(
AccountEmailTemplates.MailSecurityVerifyLink,
displayName: LocalizableString.Create<AbpAccountResource>(
$"TextTemplate:{AccountEmailTemplates.MailSecurityVerifyLink}"),
layout: StandardEmailTemplates.Layout,
localizationResource: typeof(AbpAccountResource)
).WithVirtualFilePath("/LINGYUN/Abp/Account/Emailing/Templates/MailSecurityVerify.tpl", true)
);
}
}

8
aspnet-core/modules/account/LINGYUN.Abp.Account.Domain.Shared/LINGYUN/Abp/Account/Localization/AbpAccountResource.cs

@ -1,8 +0,0 @@
using Volo.Abp.Localization;
namespace LINGYUN.Abp.Account.Localization;
[LocalizationResourceName("AbpAccountResource")]
public class AbpAccountResource
{
}

3
aspnet-core/modules/account/LINGYUN.Abp.Account.Domain/FodyWeavers.xml

@ -1,3 +0,0 @@
<Weavers xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="FodyWeavers.xsd">
<ConfigureAwait ContinueOnCapturedContext="false" />
</Weavers>

18
aspnet-core/modules/account/LINGYUN.Abp.Account.Domain/LINGYUN.Abp.Account.Domain.csproj

@ -1,18 +0,0 @@
<Project Sdk="Microsoft.NET.Sdk">
<Import Project="..\..\..\common.props" />
<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
<RootNamespace />
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Volo.Abp.Identity.Domain" Version="4.4.0" />
</ItemGroup>
<ItemGroup>
<Folder Include="Microsoft\AspNetCore\Identity\" />
</ItemGroup>
</Project>

9
aspnet-core/modules/account/LINGYUN.Abp.Account.Domain/LINGYUN/Abp/Account/AbpAccountDomainModule.cs

@ -1,9 +0,0 @@
using Volo.Abp.Modularity;
namespace LINGYUN.Abp.Account
{
[DependsOn(typeof(AbpAccountDomainSharedModule))]
public class AbpAccountDomainModule : AbpModule
{
}
}

16
aspnet-core/modules/account/LINGYUN.Abp.Account.Domain/LINGYUN/Abp/Account/IIdentityUserRepository.cs

@ -1,16 +0,0 @@
using System;
using System.Threading.Tasks;
using Volo.Abp.Domain.Repositories;
using Volo.Abp.Identity;
namespace LINGYUN.Abp.Account
{
public interface IIdentityUserRepository : IReadOnlyRepository<IdentityUser, Guid>
{
Task<bool> PhoneNumberHasRegistedAsync(string phoneNumber);
Task<IdentityUser> FindByPhoneNumberAsync(string phoneNumber);
Task<Guid?> GetIdByPhoneNumberAsync(string phoneNumber);
}
}

14
aspnet-core/modules/account/LINGYUN.Abp.Account.HttpApi/LINGYUN/Abp/Account/AbpAccountHttpApiModule.cs

@ -1,8 +1,6 @@
using LINGYUN.Abp.Account.Localization;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.DependencyInjection;
using Volo.Abp.Account.Localization;
using Volo.Abp.AspNetCore.Mvc.Localization;
using Volo.Abp.Localization;
using Volo.Abp.Modularity;
namespace LINGYUN.Abp.Account
@ -26,15 +24,5 @@ namespace LINGYUN.Abp.Account
mvcBuilder.AddApplicationPartIfNotExists(typeof(AbpAccountHttpApiModule).Assembly);
});
}
public override void ConfigureServices(ServiceConfigurationContext context)
{
Configure<AbpLocalizationOptions>(options =>
{
options.Resources
.Get<AccountResource>()
.AddBaseTypes(typeof(AbpAccountResource));
});
}
}
}

14
aspnet-core/modules/account/LINGYUN.Abp.Account.HttpApi/LINGYUN/Abp/Account/MyProfileController.cs

@ -47,5 +47,19 @@ namespace LINGYUN.Abp.Account
{
await MyProfileAppService.ChangePhoneNumberAsync(input);
}
[HttpPut]
[Route("send-email-confirm-link")]
public async virtual Task SendEmailConfirmLinkAsync(SendEmailConfirmCodeDto input)
{
await MyProfileAppService.SendEmailConfirmLinkAsync(input);
}
[HttpPut]
[Route("confirm-email")]
public async virtual Task ConfirmEmailAsync(ConfirmEmailInput input)
{
await MyProfileAppService.ConfirmEmailAsync(input);
}
}
}

0
aspnet-core/modules/account/LINGYUN.Abp.Account.Domain.Shared/FodyWeavers.xml → aspnet-core/modules/account/LINGYUN.Abp.Account.Templates/FodyWeavers.xml

0
aspnet-core/modules/account/LINGYUN.Abp.Account.Domain.Shared/FodyWeavers.xsd → aspnet-core/modules/account/LINGYUN.Abp.Account.Templates/FodyWeavers.xsd

54
aspnet-core/modules/account/LINGYUN.Abp.Account.Domain.Shared/LINGYUN.Abp.Account.Domain.Shared.csproj → aspnet-core/modules/account/LINGYUN.Abp.Account.Templates/LINGYUN.Abp.Account.Templates.csproj

@ -1,25 +1,29 @@
<Project Sdk="Microsoft.NET.Sdk">
<Import Project="..\..\..\configureawait.props" />
<Import Project="..\..\..\common.props" />
<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
<RootNamespace />
</PropertyGroup>
<ItemGroup>
<None Remove="LINGYUN\Abp\Account\Emailing\Templates\*.tpl" />
<None Remove="LINGYUN\Abp\Account\Localization\Resources\*.json" />
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="LINGYUN\Abp\Account\Emailing\Templates\*.tpl" />
<EmbeddedResource Include="LINGYUN\Abp\Account\Localization\Resources\*.json" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Volo.Abp.Emailing" Version="$(VoloAbpPackageVersion)" />
</ItemGroup>
</Project>
<Project Sdk="Microsoft.NET.Sdk">
<Import Project="..\..\..\configureawait.props" />
<Import Project="..\..\..\common.props" />
<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
<RootNamespace />
</PropertyGroup>
<ItemGroup>
<None Remove="LINGYUN\Abp\Account\Emailing\Templates\*.tpl" />
<None Remove="LINGYUN\Abp\Account\Templates\Localization\Resources\*.json" />
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="LINGYUN\Abp\Account\Emailing\Templates\*.tpl" />
<EmbeddedResource Include="LINGYUN\Abp\Account\Templates\Localization\Resources\*.json" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Volo.Abp.Emailing" Version="$(VoloAbpPackageVersion)" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\LINGYUN.Abp.Account.Application.Contracts\LINGYUN.Abp.Account.Application.Contracts.csproj" />
</ItemGroup>
</Project>

6
aspnet-core/modules/account/LINGYUN.Abp.Account.Domain.Shared/LINGYUN/Abp/Account/Emailing/Templates/AccountEmailTemplates.cs → aspnet-core/modules/account/LINGYUN.Abp.Account.Templates/LINGYUN/Abp/Account/Emailing/Templates/AccountEmailTemplates.cs

@ -1,7 +1,11 @@
namespace LY.MicroService.IdentityServer.Emailing.Templates;
namespace LINGYUN.Abp.Account.Emailing.Templates;
public static class AccountEmailTemplates
{
/// <summary>
/// 邮件地址确认
/// </summary>
public const string MailConfirmLink = "Abp.Account.MailConfirmLink";
/// <summary>
/// 邮件安全验证
/// </summary>

32
aspnet-core/modules/account/LINGYUN.Abp.Account.Templates/LINGYUN/Abp/Account/Emailing/Templates/AccountTemplateDefinitionProvider.cs

@ -0,0 +1,32 @@
using Volo.Abp.Account.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(AccountResource)
).WithVirtualFilePath("/LINGYUN/Abp/Account/Emailing/Templates/MailSecurityVerify.tpl", true),
new TemplateDefinition(
AccountEmailTemplates.MailConfirmLink,
displayName: L($"TextTemplate:{AccountEmailTemplates.MailConfirmLink}"),
layout: StandardEmailTemplates.Layout,
localizationResource: typeof(AccountResource)
).WithVirtualFilePath("/LINGYUN/Abp/Account/Emailing/Templates/MailConfirm.tpl", true)
);
}
private static ILocalizableString L(string name)
{
return LocalizableString.Create<AccountResource>(name);
}
}

7
aspnet-core/modules/account/LINGYUN.Abp.Account.Templates/LINGYUN/Abp/Account/Emailing/Templates/MailConfirm.tpl

@ -0,0 +1,7 @@
<h3>{{L "EmailConfirm"}}</h3>
<p>{{L "EmailConfirmInfo"}}</p>
<div>
<a href="{{model.link}}">{{L "ConfirmMyEmail"}}</a>
</div>

0
aspnet-core/modules/account/LINGYUN.Abp.Account.Domain.Shared/LINGYUN/Abp/Account/Emailing/Templates/MailSecurityVerify.tpl → aspnet-core/modules/account/LINGYUN.Abp.Account.Templates/LINGYUN/Abp/Account/Emailing/Templates/MailSecurityVerify.tpl

13
aspnet-core/modules/account/LINGYUN.Abp.Account.Templates/LINGYUN/Abp/Account/Templates/AbpAccountTemplatesModule.cs

@ -0,0 +1,13 @@
using Volo.Abp.Emailing;
using Volo.Abp.Modularity;
namespace LINGYUN.Abp.Account.Templates
{
[DependsOn(
typeof(AbpEmailingModule),
typeof(AbpAccountApplicationContractsModule))]
public class AbpAccountTemplatesModule : AbpModule
{
}
}

16
aspnet-core/modules/account/LINGYUN.Abp.Account.Templates/LINGYUN/Abp/Account/Templates/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}<br/><p>Your email security verification code is as follows. Please enter the verification code to proceed to the next step.</p><p>If not operated by you, please ignore this email.</p>",
"MailSecurityVerifyRemarks": "<p>(If it is not in the form of a link, copy the address to the browser address bar for further access)</p><p>Thank you for your visit and have a good time!</p>",
"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."
}
}

16
aspnet-core/modules/account/LINGYUN.Abp.Account.Templates/LINGYUN/Abp/Account/Templates/Localization/Resources/zh-Hans.json

@ -0,0 +1,16 @@
{
"culture": "zh-Hans",
"texts": {
"TextTemplate:Abp.Account.MailSecurityVerifyLink": "邮件验证模板",
"TextTemplate:Abp.Account.MailConfirmLink": "邮件确认模板",
"MailSecurityVerify": "邮件安全验证",
"VerifyMyEmailAddress": "您好<br/><p>您此次邮件安全验证码如下,请输入验证码进行下一步操作。</p><p>如非你本人操作,请忽略此邮件。</p>",
"MailSecurityVerifyRemarks": "此邮件为系统所发,请勿直接回复。",
"ClickToValidation": "点击进行验证",
"Validation": "验证",
"EmailConfirm": "邮件确认",
"EmailConfirmInfo": "我们收到了邮件确认请求!如果你发起了此请求,请单击以下链接以确认邮件地址.",
"ConfirmMyEmail": "绑定我的邮箱地址",
"YourEmailIsSuccessfullyConfirm": "您的邮件地址绑定成功."
}
}

2
aspnet-core/modules/cli/LINGYUN.Abp.Cli/LINGYUN.Abp.Cli.csproj

@ -5,7 +5,7 @@
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net6.0</TargetFramework>
<Version>5.3.0</Version>
<Version>5.3.2</Version>
<Copyright>colin</Copyright>
<Description>Use LINGYUN.MicroService.Templates command line</Description>
<PackAsTool>true</PackAsTool>

2
aspnet-core/modules/identity/LINGYUN.Abp.Identity.Domain.Shared/LINGYUN.Abp.Identity.Domain.Shared.csproj

@ -1,4 +1,4 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">
<Import Project="..\..\..\configureawait.props" />
<Import Project="..\..\..\common.props" />

20
aspnet-core/modules/identity/LINGYUN.Abp.Identity.Domain.Shared/LINGYUN/Abp/Identity/IUserSecurityCodeSender.cs

@ -1,20 +0,0 @@
using System.Threading;
using System.Threading.Tasks;
namespace LINGYUN.Abp.Identity
{
public interface IUserSecurityCodeSender
{
Task SendPhoneConfirmedCodeAsync(
string phone,
string token,
string template, // 传递模板号
CancellationToken cancellation = default);
Task SendEmailConfirmedCodeAsync(
string userName,
string email,
string token,
CancellationToken cancellation = default);
}
}

4
aspnet-core/modules/identity/LINGYUN.Abp.Identity.Domain.Shared/LINGYUN/Abp/Identity/IdentityErrorCodes.cs

@ -22,5 +22,9 @@
/// 你不能修改你的邮件绑定信息
/// </summary>
public const string UsersCanNotChangeEmailAddress = "Volo.Abp.Identity:020009";
/// <summary>
/// 重复确认的邮件地址
/// </summary>
public const string DuplicateConfirmEmailAddress = "Volo.Abp.Identity:020010";
}
}

1
aspnet-core/modules/identity/LINGYUN.Abp.Identity.Domain.Shared/LINGYUN/Abp/Identity/Localization/en.json

@ -46,6 +46,7 @@
"Volo.Abp.Identity:020007": "The phone number is already tied to another user!",
"Volo.Abp.Identity:020008": "You can't modify your phone's binding information!",
"Volo.Abp.Identity:020009": "You cannot modify your email binding information!",
"Volo.Abp.Identity:020010": "The email address is bound!",
"Volo.Abp.Identity:DuplicatePhoneNumber": "Phone number '{0}' is already taken.",
"DisplayName:Abp.Identity.User.SmsNewUserRegister": "Register sms template",
"Description:Abp.Identity.User.SmsNewUserRegister": "When the user registers, he/she should send the template number of the SMS verification code and fill in the template number of the corresponding cloud platform registration",

5
aspnet-core/modules/identity/LINGYUN.Abp.Identity.Domain.Shared/LINGYUN/Abp/Identity/Localization/zh-Hans.json

@ -46,6 +46,7 @@
"Volo.Abp.Identity:020007": "手机号码已被其他用户绑定!",
"Volo.Abp.Identity:020008": "你不能修改你的手机绑定信息!",
"Volo.Abp.Identity:020009": "你不能修改你的邮件绑定信息!",
"Volo.Abp.Identity:020010": "邮件地址已绑定!",
"Volo.Abp.Identity:DuplicatePhoneNumber": "手机号 '{0}' 已存在.",
"DisplayName:Abp.Identity.User.SmsNewUserRegister": "新用户注册模板",
"Description:Abp.Identity.User.SmsNewUserRegister": "新用户通过手机注册账号验证码模板",
@ -55,8 +56,8 @@
"Description:Abp.Identity.User.SmsResetPassword": "用户通过手机找回密码验证码模板",
"DisplayName:Abp.Identity.User.SmsPhoneNumberConfirmed": "手机确认模板",
"Description:Abp.Identity.User.SmsPhoneNumberConfirmed": "用户确认手机号验证码模板",
"DisplayName:Abp.Identity.User.SmsRepetInterval": "重复发送间隔时间(min)",
"Description:Abp.Identity.User.SmsRepetInterval": "验证码重复发送的最小时间差,单位为分",
"DisplayName:Abp.Identity.User.SmsRepetInterval": "短信验证码重复发送间隔时间(min)",
"Description:Abp.Identity.User.SmsRepetInterval": "短信验证码验证码重复发送的最小时间差,单位为分",
"DisplayName:SmsVerifyCode": "短信验证码",
"DisplayName:EmailVerifyCode": "邮件验证码",
"DisplayName:WeChatCode": "微信登录凭证",

2
aspnet-core/modules/identity/LINGYUN.Abp.Identity.Domain.Shared/LINGYUN/Abp/Identity/Settings/IdentitySettingNames.cs

@ -23,7 +23,7 @@
/// </summary>
public const string SmsResetPassword = UserPrefix + ".SmsResetPassword";
/// <summary>
/// 验证码重复间隔时间
/// 短信验证码重复间隔时间
/// </summary>
public const string SmsRepetInterval = UserPrefix + ".SmsRepetInterval";
}

21
aspnet-core/modules/identity/LINGYUN.Abp.Identity.Domain/LINGYUN/Abp/Identity/SmsSecurityTokenCacheItem.cs → aspnet-core/modules/identity/LINGYUN.Abp.Identity.Domain/LINGYUN/Abp/Identity/SecurityTokenCacheItem.cs

@ -1,9 +1,9 @@
namespace LINGYUN.Abp.Identity
{
/// <summary>
/// 短信安全令牌验证缓存
/// 安全令牌验证缓存
/// </summary>
public class SmsSecurityTokenCacheItem
public class SecurityTokenCacheItem
{
/// <summary>
/// 用于验证的Token
@ -14,12 +14,12 @@
/// </summary>
public string SecurityToken { get; set; }
public SmsSecurityTokenCacheItem()
public SecurityTokenCacheItem()
{
}
public SmsSecurityTokenCacheItem(string token, string securityToken)
public SecurityTokenCacheItem(string token, string securityToken)
{
Token = token;
SecurityToken = securityToken;
@ -31,9 +31,20 @@
/// <param name="phoneNumber">手机号</param>
/// <param name="purpose">安全令牌用途</param>
/// <returns></returns>
public static string CalculateCacheKey(string phoneNumber, string purpose)
public static string CalculateSmsCacheKey(string phoneNumber, string purpose)
{
return "Totp:" + purpose + ";p:" + phoneNumber;
}
/// <summary>
/// 生成查询Key
/// </summary>
/// <param name="email">邮件地址</param>
/// <param name="purpose">安全令牌用途</param>
/// <returns></returns>
public static string CalculateEmailCacheKey(string email, string purpose)
{
return "Totp:" + purpose + ";e:" + email;
}
}
}

2
aspnet-core/modules/platform/LINGYUN.Platform.Application.Contracts/LINGYUN/Platform/Menus/Dto/MenuCreateDto.cs

@ -5,8 +5,6 @@ namespace LINGYUN.Platform.Menus
{
public class MenuCreateDto : MenuCreateOrUpdateDto
{
public Guid? ParentId { get; set; }
[Required]
public Guid LayoutId { get; set; }
}

3
aspnet-core/modules/platform/LINGYUN.Platform.Application.Contracts/LINGYUN/Platform/Menus/Dto/MenuCreateOrUpdateDto.cs

@ -1,4 +1,5 @@
using LINGYUN.Platform.Routes;
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using Volo.Abp.Validation;
@ -7,6 +8,8 @@ namespace LINGYUN.Platform.Menus
{
public class MenuCreateOrUpdateDto
{
public Guid? ParentId { get; set; }
[Required]
[DynamicStringLength(typeof(RouteConsts), nameof(RouteConsts.MaxNameLength))]
public string Name { get; set; }

1
aspnet-core/modules/platform/LINGYUN.Platform.Application/LINGYUN/Platform/Menus/MenuAppService.cs

@ -211,6 +211,7 @@ namespace LINGYUN.Platform.Menus
menu.Component = input.Component;
}
menu.ParentId = input.ParentId;
menu.IsPublic = input.IsPublic;
await MenuManager.UpdateAsync(menu);

6
aspnet-core/modules/task-management/LINGYUN.Abp.BackgroundTasks.ExceptionHandling/LINGYUN/Abp/BackgroundTasks/ExceptionHandling/JobExecutedFailedProvider.cs

@ -98,9 +98,9 @@ public class JobExecutedFailedProvider : JobExecutedProvider, ITransientDependen
{
Title = subject,
Id = context.Event.EventData.Key,
Group = context.Action.Paramters.GetOrDefault(nameof(JobInfo.Group)) ?? context.Event.EventData.Group,
Name = context.Action.Paramters.GetOrDefault(nameof(JobInfo.Name)) ?? context.Event.EventData.Name,
Type = context.Action.Paramters.GetOrDefault(nameof(JobInfo.Type)) ?? context.Event.EventData.Type.Name,
Group = context.Event.EventData.Args.GetOrDefault(nameof(JobInfo.Group)) ?? context.Event.EventData.Group,
Name = context.Event.EventData.Args.GetOrDefault(nameof(JobInfo.Name)) ?? context.Event.EventData.Name,
Type = context.Event.EventData.Args.GetOrDefault(nameof(JobInfo.Type)) ?? context.Event.EventData.Type.Name,
Triggertime = context.Event.EventData.RunTime.ToString("yyyy-MM-dd HH:mm:ss"),
Message = errorMessage,
Tenantname = context.Action.Paramters.GetOrDefault(nameof(IMultiTenant.TenantId)),

5
aspnet-core/services/LY.MicroService.identityServer.HttpApi.Host/Emailing/Templates/EmailConfirmed.tpl

@ -1,5 +0,0 @@
<div style="position: absolute;">
<span>{{L "EmailConfirmed" model.user}}</span>
<p style="display:block; padding:0 50px; width: 150px; height:48px; line-height:48px; color:#cc0000; font-size:26px; background:#9c9797; font-weight:bold;">{{model.code}}</p>
<span>{{L "EmailConfirmedRemarks"}}</span>
</div>

26
aspnet-core/services/LY.MicroService.identityServer.HttpApi.Host/Emailing/Templates/IdentityEmailTemplateDefinitionProvider.cs

@ -1,26 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Volo.Abp.Emailing.Templates;
using Volo.Abp.Localization;
using Volo.Abp.TextTemplating;
using Volo.Abp.Identity.Localization;
namespace LY.MicroService.IdentityServer.Emailing.Templates
{
public class IdentityEmailTemplateDefinitionProvider : TemplateDefinitionProvider
{
public override void Define(ITemplateDefinitionContext context)
{
context.Add(
new TemplateDefinition(
IdentityEmailTemplates.EmailConfirmed,
displayName: LocalizableString.Create<IdentityResource>($"TextTemplate:{IdentityEmailTemplates.EmailConfirmed}"),
layout: StandardEmailTemplates.Layout,
localizationResource: typeof(IdentityResource)
).WithVirtualFilePath("/LINGYUN/Abp/IdentityServer4/Emailing/Templates/EmailConfirmed.tpl", true)
);
}
}
}

7
aspnet-core/services/LY.MicroService.identityServer.HttpApi.Host/Emailing/Templates/IdentityEmailTemplates.cs

@ -1,7 +0,0 @@
namespace LY.MicroService.IdentityServer.Emailing.Templates
{
public static class IdentityEmailTemplates
{
public const string EmailConfirmed = "Abp.Identity.EmailConfirmed";
}
}

5
aspnet-core/services/LY.MicroService.identityServer.HttpApi.Host/LY.MicroService.identityServer.HttpApi.Host.csproj

@ -10,11 +10,6 @@
</ItemGroup>
<ItemGroup>
<None Remove="Emailing\Templates\EmailConfirmed.tpl" />
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="Emailing\Templates\EmailConfirmed.tpl" />
<EmbeddedResource Include="Localization\Resources\*.json" />
</ItemGroup>

65
aspnet-core/services/LY.MicroService.identityServer.HttpApi.Host/UserSecurityCodeSender.cs

@ -1,65 +0,0 @@
using LINGYUN.Abp.Identity;
using LY.MicroService.IdentityServer.Emailing.Templates;
using Microsoft.Extensions.Localization;
using System.Threading;
using System.Threading.Tasks;
using Volo.Abp;
using Volo.Abp.DependencyInjection;
using Volo.Abp.Emailing;
using Volo.Abp.Identity.Localization;
using Volo.Abp.Sms;
using Volo.Abp.TextTemplating;
namespace LY.MicroService.IdentityServer;
public class UserSecurityCodeSender : IUserSecurityCodeSender, ITransientDependency
{
protected IEmailSender EmailSender { get; }
protected ITemplateRenderer TemplateRenderer { get; }
protected IStringLocalizer<IdentityResource> Localizer { get; }
protected ISmsSender SmsSender { get; }
public UserSecurityCodeSender(
ISmsSender smsSender,
IEmailSender emailSender,
ITemplateRenderer templateRenderer,
IStringLocalizer<IdentityResource> localizer)
{
SmsSender = smsSender;
EmailSender = emailSender;
TemplateRenderer = templateRenderer;
Localizer = localizer;
}
public virtual async Task SendEmailConfirmedCodeAsync(
string userName,
string email,
string token,
CancellationToken cancellation = default)
{
var emailContent = await TemplateRenderer.RenderAsync(
IdentityEmailTemplates.EmailConfirmed,
new { user = userName, code = token });
await EmailSender.SendAsync(
email,
Localizer["EmailConfirmed"],
emailContent);
}
public virtual async Task SendPhoneConfirmedCodeAsync(
string phone,
string token,
string template,
CancellationToken cancellation = default)
{
Check.NotNullOrWhiteSpace(template, nameof(template));
var smsMessage = new SmsMessage(phone, token);
smsMessage.Properties.Add("code", token);
smsMessage.Properties.Add("TemplateCode", template);
await SmsSender.SendAsync(smsMessage);
}
}

6
aspnet-core/services/LY.MicroService.identityServer/IdentityServerModule.Configure.cs

@ -1,5 +1,4 @@
using DotNetCore.CAP;
using LINGYUN.Abp.Account.Localization;
using LINGYUN.Abp.IdentityServer.IdentityResources;
using LINGYUN.Abp.Localization.CultureMap;
using LINGYUN.Abp.Serilog.Enrichers.Application;
@ -180,7 +179,6 @@ public partial class IdentityServerModule
options.Resources
.Get<AccountResource>()
.AddBaseTypes(typeof(AbpAccountResource))
.AddVirtualJson("/Localization/Resources");
});
@ -209,8 +207,10 @@ public partial class IdentityServerModule
Configure<AppUrlOptions>(options =>
{
options.Applications["MVC"].RootUrl = configuration["App:SelfUrl"];
// 邮件登录地址
options.Applications["VUE"].RootUrl = configuration["App:VueUrl"];
options.Applications["MVC"].Urls["EmailVerifyLogin"] = "Account/VerifyCode";
options.Applications["MVC"].Urls["EmailConfirm"] = "Account/EmailConfirm";
});
}
private void ConfigureSecurity(IServiceCollection services, IConfiguration configuration, bool isDevelopment = false)

2
aspnet-core/services/LY.MicroService.identityServer/IdentityServerModule.cs

@ -20,7 +20,6 @@ using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using Volo.Abp;
using Volo.Abp.Account;
using Volo.Abp.Account.Web;
using Volo.Abp.AspNetCore.Authentication.JwtBearer;
using Volo.Abp.AspNetCore.Mvc.UI.Theme.Basic;
@ -45,7 +44,6 @@ namespace LY.MicroService.IdentityServer;
typeof(AbpAspNetCoreSerilogModule),
typeof(AbpAccountWebIdentityServerModule),
typeof(AbpAccountApplicationModule),
typeof(AbpAccountDomainSharedModule),
typeof(AbpAspNetCoreMvcUiBasicThemeModule),
typeof(AbpAutofacModule),
typeof(AbpCachingStackExchangeRedisModule),

2
aspnet-core/services/LY.MicroService.identityServer/LY.MicroService.IdentityServer.csproj

@ -45,7 +45,7 @@
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\modules\account\LINGYUN.Abp.Account.Domain.Shared\LINGYUN.Abp.Account.Domain.Shared.csproj" />
<ProjectReference Include="..\..\modules\account\LINGYUN.Abp.Account.Application\LINGYUN.Abp.Account.Application.csproj" />
<ProjectReference Include="..\..\modules\auditing\LINGYUN.Abp.AuditLogging.Elasticsearch\LINGYUN.Abp.AuditLogging.Elasticsearch.csproj" />
<ProjectReference Include="..\..\modules\authorization\LINGYUN.Abp.Identity.OrganizaztionUnits\LINGYUN.Abp.Identity.OrganizaztionUnits.csproj" />
<ProjectReference Include="..\..\modules\common\LINGYUN.Abp.AspNetCore.HttpOverrides\LINGYUN.Abp.AspNetCore.HttpOverrides.csproj" />

56
aspnet-core/services/LY.MicroService.identityServer/Pages/Account/Components/ProfileManagementGroup/PersonalInfo/Default.cshtml

@ -0,0 +1,56 @@
@using Volo.Abp.Account.Localization
@using Volo.Abp.Users
@using Microsoft.AspNetCore.Mvc.Localization
@using Volo.Abp.AspNetCore.Mvc.UI.Theming
@using Volo.Abp.Identity.Settings
@using Volo.Abp.Settings
@inject IHtmlLocalizer<AccountResource> L
@inject ICurrentUser CurrentUser
@inject ISettingProvider SettingManager
@inject IThemeManager ThemeManager
@model Volo.Abp.Account.Web.Pages.Account.Components.ProfileManagementGroup.PersonalInfo.AccountProfilePersonalInfoManagementGroupViewComponent.PersonalInfoModel
@{
var isUserNameUpdateEnabled = string.Equals(await SettingManager.GetOrNullAsync(IdentitySettingNames.User.IsUserNameUpdateEnabled), "true",
StringComparison.OrdinalIgnoreCase);
var isEmailUpdateEnabled = string.Equals(await SettingManager.GetOrNullAsync(IdentitySettingNames.User.IsEmailUpdateEnabled), "true",
StringComparison.OrdinalIgnoreCase);
}
<h4>@L["PersonalSettings"]</h4><hr/>
<form method="post" id="PersonalSettingsForm">
<input asp-for="ConcurrencyStamp" />
<abp-input asp-for="UserName" readonly="!isUserNameUpdateEnabled"/>
<abp-row>
<abp-column size-md="_6">
<abp-input asp-for="Name"/>
</abp-column>
<abp-column size-md="_6">
<abp-input asp-for="Surname"/>
</abp-column>
</abp-row>
<abp-row>
<abp-column size-md="_9">
<abp-input asp-for="Email" readonly="!isEmailUpdateEnabled"/>
</abp-column>
<abp-column size-md="_3">
@if (CurrentUser.EmailVerified)
{
<abp-button button-type="Success" text="@L["Confirmed"].Value"/>
}
else
{
<a href="/Account/SendEmailConfirm">@L["Validation"].Value</a>
}
</abp-column>
</abp-row>
<abp-input asp-for="PhoneNumber"/>
<abp-button type="submit" button-type="Primary" text="@L["Submit"].Value"/>
</form>

28
aspnet-core/services/LY.MicroService.identityServer/Pages/Account/Components/ProfileManagementGroup/PersonalInfo/Default.js

@ -0,0 +1,28 @@
(function ($) {
$(function () {
var l = abp.localization.getResource("AbpAccount");
$('#PersonalSettingsForm').submit(function (e) {
e.preventDefault();
if (!$('#PersonalSettingsForm').valid()) {
return false;
}
var input = $('#PersonalSettingsForm').serializeFormToObject();
volo.abp.account.profile.update(input).then(function (result) {
abp.notify.success(l('PersonalSettingsSaved'));
updateConcurrencyStamp();
});
});
});
abp.event.on('passwordChanged', updateConcurrencyStamp);
function updateConcurrencyStamp(){
volo.abp.account.profile.get().then(function(profile){
$("#ConcurrencyStamp").val(profile.concurrencyStamp);
});
}
})(jQuery);

17
aspnet-core/services/LY.MicroService.identityServer/Pages/Account/EmailConfirm.cshtml

@ -0,0 +1,17 @@
@page
@inject IHtmlLocalizer<AccountResource> L
@using Microsoft.AspNetCore.Mvc.Localization
@using Volo.Abp.Account.Localization
@model LY.MicroService.IdentityServer.Pages.Account.EmailConfirmModel
@inject Volo.Abp.AspNetCore.Mvc.UI.Layout.IPageLayout PageLayout
<div class="card mt-3 shadow-sm rounded">
<div class="card-body p-5">
<h4>@L["EmailConfirm"]</h4>
<form method="post">
<abp-input asp-for="UserId"/>
<abp-input asp-for="ConfirmToken"/>
<a abp-button="Secondary" asp-page="./Login">@L["Cancel"]</a>
<abp-button type="submit" button-type="Primary" text="@L["Submit"].Value"/>
</form>
</div>
</div>

75
aspnet-core/services/LY.MicroService.identityServer/Pages/Account/EmailConfirm.cshtml.cs

@ -0,0 +1,75 @@
using LINGYUN.Abp.Account;
using Microsoft.AspNetCore.Mvc;
using System;
using System.ComponentModel.DataAnnotations;
using System.Threading.Tasks;
using Volo.Abp.Account.Localization;
using Volo.Abp.Account.Web.Pages.Account;
using Volo.Abp.Identity;
using Volo.Abp.Validation;
namespace LY.MicroService.IdentityServer.Pages.Account
{
public class EmailConfirmModel : AccountPageModel
{
[Required]
[HiddenInput]
[BindProperty(SupportsGet = true)]
public Guid UserId { get; set; }
[Required]
[HiddenInput]
[BindProperty(SupportsGet = true)]
public string ConfirmToken { get; set; }
[HiddenInput]
[BindProperty(SupportsGet = true)]
public string ReturnUrl { get; set; }
[HiddenInput]
[BindProperty(SupportsGet = true)]
public string ReturnUrlHash { get; set; }
public IMyProfileAppService MyProfileAppService { get; set; }
public EmailConfirmModel()
{
LocalizationResourceType = typeof(AccountResource);
}
public async virtual Task<IActionResult> OnPostAsync()
{
try
{
ValidateModel();
await MyProfileAppService.ConfirmEmailAsync(
new ConfirmEmailInput
{
UserId = UserId,
ConfirmToken = ConfirmToken,
});
}
catch (AbpIdentityResultException e)
{
if (!string.IsNullOrWhiteSpace(e.Message))
{
Alerts.Warning(GetLocalizeExceptionMessage(e));
return Page();
}
throw;
}
catch (AbpValidationException)
{
return Page();
}
return RedirectToPage("./ConfirmEmailConfirmation", new
{
returnUrl = ReturnUrl,
returnUrlHash = ReturnUrlHash
});
}
}
}

13
aspnet-core/services/LY.MicroService.identityServer/Pages/Account/EmailConfirmConfirmation.cshtml

@ -0,0 +1,13 @@
@page
@model LY.MicroService.IdentityServer.Pages.Account.EmailConfirmConfirmationModel
@inject Volo.Abp.AspNetCore.Mvc.UI.Layout.IPageLayout PageLayout
@using Microsoft.AspNetCore.Mvc.Localization
@using Volo.Abp.Account.Localization
@inject IHtmlLocalizer<AccountResource> L
<div class="card mt-3 shadow-sm rounded">
<div class="card-body p-5">
<h4>@L["EmailConfirm"]</h4>
<p>@L["YourEmailIsSuccessfullyConfirm"]</p>
<a abp-button="Primary" href="@Url.Content(Model.ReturnUrl)">@L["GoToTheApplication"]</a>
</div>
</div>

23
aspnet-core/services/LY.MicroService.identityServer/Pages/Account/EmailConfirmConfirmation.cshtml.cs

@ -0,0 +1,23 @@
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using System.Threading.Tasks;
using Volo.Abp.Account.Web.Pages.Account;
namespace LY.MicroService.IdentityServer.Pages.Account;
[AllowAnonymous]
public class EmailConfirmConfirmationModel : AccountPageModel
{
[BindProperty(SupportsGet = true)]
public string ReturnUrl { get; set; }
[BindProperty(SupportsGet = true)]
public string ReturnUrlHash { get; set; }
public virtual Task<IActionResult> OnGetAsync()
{
ReturnUrl = GetRedirectUrl(ReturnUrl, ReturnUrlHash);
return Task.FromResult<IActionResult>(Page());
}
}

16
aspnet-core/services/LY.MicroService.identityServer/Pages/Account/SendEmailConfirm.cshtml

@ -0,0 +1,16 @@
@page
@inject IHtmlLocalizer<AccountResource> L
@using Microsoft.AspNetCore.Mvc.Localization
@using Volo.Abp.Account.Localization
@model LY.MicroService.IdentityServer.Pages.Account.SendEmailConfirmModel
@inject Volo.Abp.AspNetCore.Mvc.UI.Layout.IPageLayout PageLayout
<div class="card mt-3 shadow-sm rounded">
<div class="card-body p-5">
<h4>@L["EmailConfirm"]</h4>
<form method="post">
<abp-input asp-for="Email" readonly="true" />
<a abp-button="Secondary" asp-page="./Login">@L["Cancel"]</a>
<abp-button type="submit" button-type="Primary" text="@L["ClickToValidation"].Value"/>
</form>
</div>
</div>

75
aspnet-core/services/LY.MicroService.identityServer/Pages/Account/SendEmailConfirm.cshtml.cs

@ -0,0 +1,75 @@
using LINGYUN.Abp.Account;
using Microsoft.AspNetCore.Mvc;
using System.ComponentModel.DataAnnotations;
using System.Threading.Tasks;
using Volo.Abp.Account.Localization;
using Volo.Abp.Account.Web.Pages.Account;
using Volo.Abp.Identity;
using Volo.Abp.Validation;
namespace LY.MicroService.IdentityServer.Pages.Account
{
public class SendEmailConfirmModel : AccountPageModel
{
[BindProperty(SupportsGet = true)]
public string Email { get; set; }
[HiddenInput]
[BindProperty(SupportsGet = true)]
public string ReturnUrl { get; set; }
[HiddenInput]
[BindProperty(SupportsGet = true)]
public string ReturnUrlHash { get; set; }
public IMyProfileAppService MyProfileAppService { get; set; }
public SendEmailConfirmModel()
{
LocalizationResourceType = typeof(AccountResource);
}
public virtual Task<IActionResult> OnGetAsync()
{
Email = CurrentUser.Email;
return Task.FromResult<IActionResult>(Page());
}
public async virtual Task<IActionResult> OnPostAsync()
{
try
{
ValidateModel();
await MyProfileAppService.SendEmailConfirmLinkAsync(
new SendEmailConfirmCodeDto
{
Email = Email,
AppName = "MVC",
ReturnUrl = ReturnUrl,
ReturnUrlHash = ReturnUrlHash
});
}
catch (AbpIdentityResultException e)
{
if (!string.IsNullOrWhiteSpace(e.Message))
{
Alerts.Warning(GetLocalizeExceptionMessage(e));
return Page();
}
throw;
}
catch (AbpValidationException)
{
return Page();
}
return RedirectToPage("~/Account/Manage", new
{
returnUrl = ReturnUrl
});
}
}
}

1
aspnet-core/services/LY.MicroService.identityServer/appsettings.Development.json

@ -10,6 +10,7 @@
"App": {
"TrackingEntitiesChanged": true,
"SelfUrl": "http://127.0.0.1:44385/",
"VueUrl": "http://127.0.0.1:3100/",
"CorsOrigins": "http://127.0.0.1:3100"
},
"AppSelfUrl": "http://127.0.0.1:44385/",

1
build/modules.dependencies.json

@ -56,6 +56,7 @@
"path": "/../aspnet-core/services/LY.MicroService.BackendAdmin.HttpApi.Host/Modules/",
"depPath": "/../aspnet-core/LocalNuget/netstandard2.0/",
"dependencies": [
"LINGYUN.Abp.Account.Templates.dll",
"LINGYUN.Abp.Features.LimitValidation.dll",
"LINGYUN.Abp.Features.LimitValidation.Redis.dll",
"LINGYUN.Abp.WorkflowManagement.Application.Contracts.dll",

Loading…
Cancel
Save