diff --git a/RELEASE.md b/RELEASE.md index 1b353e8e9..6d6095b3d 100644 --- a/RELEASE.md +++ b/RELEASE.md @@ -12,9 +12,13 @@ 4、移除网关管理模块, 使用本地文件作为路由配置; +5、移除动态网关数据库脚本文件; + +6、将 Profile 相关api从Identity模块移动到Account模块; + 5、加入Fody统一配置ConfigureAwait; -6、使用Directory.Build.props统一管理导入版本。 +6、使用Directory.Build.props统一管理导入版本; # [2021-03-29] 1、增加动态本地化组件支持,用于在运行时替换本地化文本,需要实现 ILocalizationStore; diff --git a/aspnet-core/modules/identity/LINGYUN.Abp.Identity.Application.Contracts/LINGYUN/Abp/Identity/Dto/ChangePhoneNumberDto.cs b/aspnet-core/modules/account/LINGYUN.Abp.Account.Application.Contracts/LINGYUN/Abp/Account/Dto/ChangePhoneNumberInput.cs similarity index 90% rename from aspnet-core/modules/identity/LINGYUN.Abp.Identity.Application.Contracts/LINGYUN/Abp/Identity/Dto/ChangePhoneNumberDto.cs rename to aspnet-core/modules/account/LINGYUN.Abp.Account.Application.Contracts/LINGYUN/Abp/Account/Dto/ChangePhoneNumberInput.cs index 363e2c96c..d98446477 100644 --- a/aspnet-core/modules/identity/LINGYUN.Abp.Identity.Application.Contracts/LINGYUN/Abp/Identity/Dto/ChangePhoneNumberDto.cs +++ b/aspnet-core/modules/account/LINGYUN.Abp.Account.Application.Contracts/LINGYUN/Abp/Account/Dto/ChangePhoneNumberInput.cs @@ -3,9 +3,9 @@ using Volo.Abp.Auditing; using Volo.Abp.Identity; using Volo.Abp.Validation; -namespace LINGYUN.Abp.Identity +namespace LINGYUN.Abp.Account { - public class ChangePhoneNumberDto + public class ChangePhoneNumberInput { /// /// 新手机号 diff --git a/aspnet-core/modules/account/LINGYUN.Abp.Account.Application.Contracts/LINGYUN/Abp/Account/Dto/ChangeUserClaimInput.cs b/aspnet-core/modules/account/LINGYUN.Abp.Account.Application.Contracts/LINGYUN/Abp/Account/Dto/ChangeUserClaimInput.cs new file mode 100644 index 000000000..5f62dcb8f --- /dev/null +++ b/aspnet-core/modules/account/LINGYUN.Abp.Account.Application.Contracts/LINGYUN/Abp/Account/Dto/ChangeUserClaimInput.cs @@ -0,0 +1,16 @@ +using System.ComponentModel.DataAnnotations; +using Volo.Abp.Identity; +using Volo.Abp.Validation; + +namespace LINGYUN.Abp.Account +{ + public class ChangeUserClaimInput + { + [Required] + [DynamicMaxLength(typeof(IdentityUserClaimConsts), nameof(IdentityUserClaimConsts.MaxClaimTypeLength))] + public string ClaimType { get; set; } + + [DynamicMaxLength(typeof(IdentityUserClaimConsts), nameof(IdentityUserClaimConsts.MaxClaimValueLength))] + public string ClaimValue { get; set; } + } +} diff --git a/aspnet-core/modules/identity/LINGYUN.Abp.Identity.Application.Contracts/LINGYUN/Abp/Identity/Dto/SendChangePhoneNumberCodeDto.cs b/aspnet-core/modules/account/LINGYUN.Abp.Account.Application.Contracts/LINGYUN/Abp/Account/Dto/SendChangePhoneNumberCodeInput.cs similarity index 84% rename from aspnet-core/modules/identity/LINGYUN.Abp.Identity.Application.Contracts/LINGYUN/Abp/Identity/Dto/SendChangePhoneNumberCodeDto.cs rename to aspnet-core/modules/account/LINGYUN.Abp.Account.Application.Contracts/LINGYUN/Abp/Account/Dto/SendChangePhoneNumberCodeInput.cs index f8a394e84..b75b65f6a 100644 --- a/aspnet-core/modules/identity/LINGYUN.Abp.Identity.Application.Contracts/LINGYUN/Abp/Identity/Dto/SendChangePhoneNumberCodeDto.cs +++ b/aspnet-core/modules/account/LINGYUN.Abp.Account.Application.Contracts/LINGYUN/Abp/Account/Dto/SendChangePhoneNumberCodeInput.cs @@ -2,9 +2,9 @@ using Volo.Abp.Identity; using Volo.Abp.Validation; -namespace LINGYUN.Abp.Identity +namespace LINGYUN.Abp.Account { - public class SendChangePhoneNumberCodeDto + public class SendChangePhoneNumberCodeInput { /// /// 新手机号 diff --git a/aspnet-core/modules/account/LINGYUN.Abp.Account.Application.Contracts/LINGYUN/Abp/Account/Dto/TwoFactorEnabledDto.cs b/aspnet-core/modules/account/LINGYUN.Abp.Account.Application.Contracts/LINGYUN/Abp/Account/Dto/TwoFactorEnabledDto.cs new file mode 100644 index 000000000..b911e1641 --- /dev/null +++ b/aspnet-core/modules/account/LINGYUN.Abp.Account.Application.Contracts/LINGYUN/Abp/Account/Dto/TwoFactorEnabledDto.cs @@ -0,0 +1,7 @@ +namespace LINGYUN.Abp.Account +{ + public class TwoFactorEnabledDto + { + public bool Enabled { get; set; } + } +} diff --git a/aspnet-core/modules/identity/LINGYUN.Abp.Identity.Application.Contracts/LINGYUN/Abp/Identity/IMyProfileAppService.cs b/aspnet-core/modules/account/LINGYUN.Abp.Account.Application.Contracts/LINGYUN/Abp/Account/IMyProfileAppService.cs similarity index 85% rename from aspnet-core/modules/identity/LINGYUN.Abp.Identity.Application.Contracts/LINGYUN/Abp/Identity/IMyProfileAppService.cs rename to aspnet-core/modules/account/LINGYUN.Abp.Account.Application.Contracts/LINGYUN/Abp/Account/IMyProfileAppService.cs index de9e8fbab..0590ec820 100644 --- a/aspnet-core/modules/identity/LINGYUN.Abp.Identity.Application.Contracts/LINGYUN/Abp/Identity/IMyProfileAppService.cs +++ b/aspnet-core/modules/account/LINGYUN.Abp.Account.Application.Contracts/LINGYUN/Abp/Account/IMyProfileAppService.cs @@ -1,7 +1,7 @@ using System.Threading.Tasks; using Volo.Abp.Application.Services; -namespace LINGYUN.Abp.Identity +namespace LINGYUN.Abp.Account { public interface IMyProfileAppService : IApplicationService { @@ -10,7 +10,7 @@ namespace LINGYUN.Abp.Identity /// /// /// - Task SetClaimAsync(IdentityUserClaimSetDto input); + Task SetClaimAsync(ChangeUserClaimInput input); /// /// 获取二次认证状态 /// @@ -27,7 +27,7 @@ namespace LINGYUN.Abp.Identity /// /// /// - Task SendChangePhoneNumberCodeAsync(SendChangePhoneNumberCodeDto input); + Task SendChangePhoneNumberCodeAsync(SendChangePhoneNumberCodeInput input); /// /// 改变手机绑定 /// @@ -36,6 +36,6 @@ namespace LINGYUN.Abp.Identity /// /// 需二次认证,主要是为了无法用到重定向页面修改相关信息的地方(点名微信小程序) /// - Task ChangePhoneNumberAsync(ChangePhoneNumberDto input); + Task ChangePhoneNumberAsync(ChangePhoneNumberInput input); } } diff --git a/aspnet-core/modules/identity/LINGYUN.Abp.Identity.Application/LINGYUN/Abp/Identity/MyProfileAppService.cs b/aspnet-core/modules/account/LINGYUN.Abp.Account.Application/LINGYUN/Abp/Account/MyProfileAppService.cs similarity index 83% rename from aspnet-core/modules/identity/LINGYUN.Abp.Identity.Application/LINGYUN/Abp/Identity/MyProfileAppService.cs rename to aspnet-core/modules/account/LINGYUN.Abp.Account.Application/LINGYUN/Abp/Account/MyProfileAppService.cs index d411798b7..65fe4d7a6 100644 --- a/aspnet-core/modules/identity/LINGYUN.Abp.Identity.Application/LINGYUN/Abp/Identity/MyProfileAppService.cs +++ b/aspnet-core/modules/account/LINGYUN.Abp.Account.Application/LINGYUN/Abp/Account/MyProfileAppService.cs @@ -1,4 +1,5 @@ -using Microsoft.AspNetCore.Authorization; +using LINGYUN.Abp.Identity; +using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Identity; using Microsoft.Extensions.Caching.Distributed; using Microsoft.Extensions.Options; @@ -6,25 +7,27 @@ using System; using System.Security.Claims; using System.Threading.Tasks; using Volo.Abp; +using Volo.Abp.Account.Localization; +using Volo.Abp.Application.Services; using Volo.Abp.Caching; using Volo.Abp.Identity; using Volo.Abp.Settings; using Volo.Abp.Users; -namespace LINGYUN.Abp.Identity +namespace LINGYUN.Abp.Account { [Authorize] - public class MyProfileAppService : IdentityAppServiceBase, IMyProfileAppService + public class MyProfileAppService : ApplicationService, IMyProfileAppService { protected IDistributedCache SecurityTokenCache { get; } protected IUserSecurityCodeSender SecurityCodeSender { get; } protected IdentityUserManager UserManager { get; } - protected IIdentityUserRepository UserRepository { get; } + protected Identity.IIdentityUserRepository UserRepository { get; } protected IOptions IdentityOptions { get; } public MyProfileAppService( IdentityUserManager userManager, - IIdentityUserRepository userRepository, + Identity.IIdentityUserRepository userRepository, IUserSecurityCodeSender securityCodeSender, IOptions identityOptions, IDistributedCache securityTokenCache) @@ -34,9 +37,11 @@ namespace LINGYUN.Abp.Identity IdentityOptions = identityOptions; SecurityCodeSender = securityCodeSender; SecurityTokenCache = securityTokenCache; + + LocalizationResource = typeof(AccountResource); } - public virtual async Task SetClaimAsync(IdentityUserClaimSetDto input) + public virtual async Task SetClaimAsync(ChangeUserClaimInput input) { await IdentityOptions.SetAsync(); var user = await UserManager.GetByIdAsync(CurrentUser.GetId()); @@ -86,11 +91,11 @@ namespace LINGYUN.Abp.Identity await CurrentUnitOfWork.SaveChangesAsync(); } - public virtual async Task SendChangePhoneNumberCodeAsync(SendChangePhoneNumberCodeDto input) + public virtual async Task SendChangePhoneNumberCodeAsync(SendChangePhoneNumberCodeInput input) { var securityTokenCacheKey = SmsSecurityTokenCacheItem.CalculateCacheKey(input.NewPhoneNumber, "SmsChangePhoneNumber"); var securityTokenCacheItem = await SecurityTokenCache.GetAsync(securityTokenCacheKey); - var interval = await SettingProvider.GetAsync(Settings.IdentitySettingNames.User.SmsRepetInterval, 1); + var interval = await SettingProvider.GetAsync(Identity.Settings.IdentitySettingNames.User.SmsRepetInterval, 1); if (securityTokenCacheItem != null) { throw new UserFriendlyException(L["SendRepeatPhoneVerifyCode", interval]); @@ -99,10 +104,10 @@ namespace LINGYUN.Abp.Identity // 是否已有用户使用手机号绑定 if (await UserRepository.IsPhoneNumberConfirmedAsync(input.NewPhoneNumber)) { - throw new BusinessException(IdentityErrorCodes.DuplicatePhoneNumber); + throw new BusinessException(Identity.IdentityErrorCodes.DuplicatePhoneNumber); } var user = await UserManager.GetByIdAsync(CurrentUser.GetId()); - var template = await SettingProvider.GetOrNullAsync(Settings.IdentitySettingNames.User.SmsPhoneNumberConfirmed); + 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); @@ -116,12 +121,12 @@ namespace LINGYUN.Abp.Identity }); } - public virtual async Task ChangePhoneNumberAsync(ChangePhoneNumberDto input) + public virtual async Task ChangePhoneNumberAsync(ChangePhoneNumberInput input) { // 是否已有用户使用手机号绑定 if (await UserRepository.IsPhoneNumberConfirmedAsync(input.NewPhoneNumber)) { - throw new BusinessException(IdentityErrorCodes.DuplicatePhoneNumber); + throw new BusinessException(Identity.IdentityErrorCodes.DuplicatePhoneNumber); } await IdentityOptions.SetAsync(); //TODO: 可以查询缓存用 securityTokenCacheItem.SecurityToken 与 user.SecurityStamp 作对比 diff --git a/aspnet-core/modules/identity/LINGYUN.Abp.Identity.HttpApi/LINGYUN/Abp/Identity/MyProfileController.cs b/aspnet-core/modules/account/LINGYUN.Abp.Account.HttpApi/LINGYUN/Abp/Account/MyProfileController.cs similarity index 84% rename from aspnet-core/modules/identity/LINGYUN.Abp.Identity.HttpApi/LINGYUN/Abp/Identity/MyProfileController.cs rename to aspnet-core/modules/account/LINGYUN.Abp.Account.HttpApi/LINGYUN/Abp/Account/MyProfileController.cs index 5a5f39388..a7da2d9c3 100644 --- a/aspnet-core/modules/identity/LINGYUN.Abp.Identity.HttpApi/LINGYUN/Abp/Identity/MyProfileController.cs +++ b/aspnet-core/modules/account/LINGYUN.Abp.Account.HttpApi/LINGYUN/Abp/Account/MyProfileController.cs @@ -4,12 +4,12 @@ using Volo.Abp; using Volo.Abp.AspNetCore.Mvc; using Volo.Abp.Identity; -namespace LINGYUN.Abp.Identity +namespace LINGYUN.Abp.Account { [RemoteService(Name = IdentityRemoteServiceConsts.RemoteServiceName)] - [Area("identity")] + [Area("account")] [ControllerName("Profile")] - [Route("/api/identity/my-profile")] + [Route("/api/account/my-profile")] public class MyProfileController : AbpController, IMyProfileAppService { protected IMyProfileAppService MyProfileAppService { get; } @@ -22,7 +22,7 @@ namespace LINGYUN.Abp.Identity [HttpPut] [Route("claims")] - public virtual async Task SetClaimAsync(IdentityUserClaimSetDto input) + public virtual async Task SetClaimAsync(ChangeUserClaimInput input) { await MyProfileAppService.SetClaimAsync(input); } @@ -43,14 +43,14 @@ namespace LINGYUN.Abp.Identity [HttpPut] [Route("send-phone-number-change-code")] - public virtual async Task SendChangePhoneNumberCodeAsync(SendChangePhoneNumberCodeDto input) + public virtual async Task SendChangePhoneNumberCodeAsync(SendChangePhoneNumberCodeInput input) { await MyProfileAppService.SendChangePhoneNumberCodeAsync(input); } [HttpPut] [Route("change-phone-number")] - public virtual async Task ChangePhoneNumberAsync(ChangePhoneNumberDto input) + public virtual async Task ChangePhoneNumberAsync(ChangePhoneNumberInput input) { await MyProfileAppService.ChangePhoneNumberAsync(input); } diff --git a/aspnet-core/modules/identity/LINGYUN.Abp.Identity.Application.Contracts/LINGYUN/Abp/Identity/Dto/ChangeEmailAddressDto.cs b/aspnet-core/modules/identity/LINGYUN.Abp.Identity.Application.Contracts/LINGYUN/Abp/Identity/Dto/ChangeEmailAddressDto.cs deleted file mode 100644 index 9422247c7..000000000 --- a/aspnet-core/modules/identity/LINGYUN.Abp.Identity.Application.Contracts/LINGYUN/Abp/Identity/Dto/ChangeEmailAddressDto.cs +++ /dev/null @@ -1,27 +0,0 @@ -using System.ComponentModel.DataAnnotations; -using Volo.Abp.Auditing; -using Volo.Abp.Identity; -using Volo.Abp.Validation; - -namespace LINGYUN.Abp.Identity -{ - public class ChangeEmailAddressDto - { - /// - /// 新邮件地址 - /// - [Required] - [EmailAddress] - [Display(Name = "EmailAddress")] - [DynamicStringLength(typeof(IdentityUserConsts), nameof(IdentityUserConsts.MaxEmailLength))] - public string NewEmailAddress { get; set; } - /// - /// 安全验证码 - /// - [Required] - [DisableAuditing] - [StringLength(6, MinimumLength = 6)] - [Display(Name = "EmailVerifyCode")] - public string Code { get; set; } - } -} diff --git a/aspnet-core/modules/identity/LINGYUN.Abp.Identity.Application.Contracts/LINGYUN/Abp/Identity/Dto/IdentityUserClaimSetDto.cs b/aspnet-core/modules/identity/LINGYUN.Abp.Identity.Application.Contracts/LINGYUN/Abp/Identity/Dto/IdentityUserClaimSetDto.cs deleted file mode 100644 index de64b2afe..000000000 --- a/aspnet-core/modules/identity/LINGYUN.Abp.Identity.Application.Contracts/LINGYUN/Abp/Identity/Dto/IdentityUserClaimSetDto.cs +++ /dev/null @@ -1,6 +0,0 @@ -namespace LINGYUN.Abp.Identity -{ - public class IdentityUserClaimSetDto : IdentityUserClaimCreateDto - { - } -} diff --git a/aspnet-core/modules/identity/LINGYUN.Abp.Identity.Application.Contracts/LINGYUN/Abp/Identity/Dto/SendChangeEmailAddressCodeDto.cs b/aspnet-core/modules/identity/LINGYUN.Abp.Identity.Application.Contracts/LINGYUN/Abp/Identity/Dto/SendChangeEmailAddressCodeDto.cs deleted file mode 100644 index a79222f6d..000000000 --- a/aspnet-core/modules/identity/LINGYUN.Abp.Identity.Application.Contracts/LINGYUN/Abp/Identity/Dto/SendChangeEmailAddressCodeDto.cs +++ /dev/null @@ -1,18 +0,0 @@ -using System.ComponentModel.DataAnnotations; -using Volo.Abp.Identity; -using Volo.Abp.Validation; - -namespace LINGYUN.Abp.Identity -{ - public class SendChangeEmailAddressCodeDto - { - /// - /// 新邮件地址 - /// - [Required] - [EmailAddress] - [Display(Name = "EmailAddress")] - [DynamicStringLength(typeof(IdentityUserConsts), nameof(IdentityUserConsts.MaxEmailLength))] - public string NewEmailAddress { get; set; } - } -}