25 changed files with 224 additions and 121 deletions
@ -1,27 +1,9 @@ |
|||
using Volo.Abp.Account.Localization; |
|||
using Volo.Abp.Localization; |
|||
using Volo.Abp.Modularity; |
|||
using Volo.Abp.VirtualFileSystem; |
|||
using Volo.Abp.Modularity; |
|||
|
|||
namespace LINGYUN.Abp.Account |
|||
{ |
|||
[DependsOn(typeof(AbpAccountDomainSharedModule))] |
|||
public class AbpAccountApplicationContractsModule : AbpModule |
|||
{ |
|||
public override void ConfigureServices(ServiceConfigurationContext context) |
|||
{ |
|||
Configure<AbpVirtualFileSystemOptions>(options => |
|||
{ |
|||
options.FileSets.AddEmbedded<AbpAccountApplicationContractsModule>(); |
|||
}); |
|||
|
|||
Configure<AbpLocalizationOptions>(options => |
|||
{ |
|||
options.Resources |
|||
.Get<Localization.AccountResource>() |
|||
.AddBaseTypes(typeof(AccountResource)) |
|||
.AddVirtualJson("/LINGYUN/Abp/Account/Localization/Resources"); |
|||
}); |
|||
} |
|||
} |
|||
} |
|||
|
|||
@ -1,8 +0,0 @@ |
|||
{ |
|||
"culture": "en", |
|||
"texts": { |
|||
"PhoneNumberNotRegisterd": "The registered mobile phone number is not registered!", |
|||
"PhoneVerifyCodeInvalid": "The phone verification code is invalid or expired!", |
|||
"PhoneVerifyCodeNotRepeatSend": "Phone verification code cannot be sent repeatedly within {0} minutes!" |
|||
} |
|||
} |
|||
@ -1,8 +0,0 @@ |
|||
{ |
|||
"culture": "zh-Hans", |
|||
"texts": { |
|||
"PhoneNumberNotRegisterd": "手机号码未注册!", |
|||
"PhoneVerifyCodeInvalid": "手机验证码无效或已经过期!", |
|||
"PhoneVerifyCodeNotRepeatSend": "手机验证码不能在 {0} 分钟内重复发送!" |
|||
} |
|||
} |
|||
@ -0,0 +1,12 @@ |
|||
<Project Sdk="Microsoft.NET.Sdk"> |
|||
|
|||
<PropertyGroup> |
|||
<TargetFramework>netstandard2.0</TargetFramework> |
|||
<RootNamespace /> |
|||
</PropertyGroup> |
|||
|
|||
<ItemGroup> |
|||
<PackageReference Include="Volo.Abp.Identity.Domain" Version="2.8.0" /> |
|||
</ItemGroup> |
|||
|
|||
</Project> |
|||
@ -0,0 +1,23 @@ |
|||
using Microsoft.AspNetCore.Identity; |
|||
using Microsoft.Extensions.Options; |
|||
using System.Collections.Generic; |
|||
using Volo.Abp.Options; |
|||
|
|||
namespace LINGYUN.Abp.Identity |
|||
{ |
|||
public class AbpIdentityOverrideOptionsFactory : AbpOptionsFactory<IdentityOptions> |
|||
{ |
|||
public AbpIdentityOverrideOptionsFactory( |
|||
IEnumerable<IConfigureOptions<IdentityOptions>> setups, |
|||
IEnumerable<IPostConfigureOptions<IdentityOptions>> postConfigures) |
|||
: base(setups, postConfigures) |
|||
{ |
|||
|
|||
} |
|||
|
|||
public override IdentityOptions Create(string name) |
|||
{ |
|||
return base.Create(name); |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,37 @@ |
|||
using Microsoft.AspNetCore.Identity; |
|||
using Microsoft.Extensions.Configuration; |
|||
using Microsoft.Extensions.DependencyInjection; |
|||
using Microsoft.Extensions.DependencyInjection.Extensions; |
|||
using Microsoft.Extensions.Options; |
|||
using System; |
|||
using Volo.Abp.Identity; |
|||
using Volo.Abp.Modularity; |
|||
|
|||
namespace LINGYUN.Abp.Identity |
|||
{ |
|||
/// <summary>
|
|||
/// 重写IdentityOptions,主要替换配置工厂组件,不再从SettingProvider获取IdentityOptions配置
|
|||
/// 在跨服务器时,从SettingProvider获取配置,用户需等待很长的时间,严重影响体验
|
|||
/// 如果是本地服务器,可以忽略这些性能影响,不需要引用此模块
|
|||
/// </summary>
|
|||
[DependsOn(typeof(AbpIdentityDomainModule))] |
|||
public class AbpIdentityOverrideOptionsModule : AbpModule |
|||
{ |
|||
public override void ConfigureServices(ServiceConfigurationContext context) |
|||
{ |
|||
// TODO:配置文件指定IdentityOptions,避免从数据库读取的超长时间等待
|
|||
// 问题点:https://github.com/abpframework/abp/blob/dev/modules/identity/src/Volo.Abp.Identity.Domain/Volo/Abp/Identity/AbpIdentityOptionsFactory.cs
|
|||
// 有11个同步等待任务去获取身份认证配置,如果缓存不存在,会执行11条数据库指令
|
|||
// 运行过程中严重影响体验
|
|||
context.Services.Replace(ServiceDescriptor.Transient<IOptionsFactory<IdentityOptions>, AbpIdentityOverrideOptionsFactory>()); |
|||
context.Services.Replace(ServiceDescriptor.Transient<IOptions<IdentityOptions>, OptionsManager<IdentityOptions>>()); |
|||
|
|||
var configuration = context.Services.GetConfiguration(); |
|||
Configure<IdentityOptions>(configuration.GetSection("Identity")); |
|||
Configure<IdentityOptions>(options => |
|||
{ |
|||
options.Lockout.DefaultLockoutTimeSpan = TimeSpan.FromSeconds(configuration.GetSection("Identity:Lockout:LockoutDuration").Get<int>()); |
|||
}); |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,49 @@ |
|||
using LINYUN.Abp.Sms.Aliyun; |
|||
using System.Collections.Generic; |
|||
using System.Threading.Tasks; |
|||
|
|||
namespace Volo.Abp.Sms |
|||
{ |
|||
public static class AliyunSmsSenderExtensions |
|||
{ |
|||
/// <summary>
|
|||
/// 扩展短信接口
|
|||
/// </summary>
|
|||
/// <param name="smsSender"></param>
|
|||
/// <param name="templateCode">短信模板号</param>
|
|||
/// <param name="phoneNumber">发送手机号</param>
|
|||
/// <param name="templateParams">短信模板参数</param>
|
|||
/// <returns></returns>
|
|||
public static async Task SendAsync(this ISmsSender smsSender, string templateCode, string phoneNumber, IDictionary<string, object> templateParams = null) |
|||
{ |
|||
var smsMessage = new SmsMessage(phoneNumber, nameof(AliyunSmsSender)); |
|||
smsMessage.Properties.Add("TemplateCode", templateCode); |
|||
if(templateParams != null) |
|||
{ |
|||
smsMessage.Properties.AddIfNotContains(templateParams); |
|||
} |
|||
await smsSender.SendAsync(smsMessage); |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// 扩展短信接口
|
|||
/// </summary>
|
|||
/// <param name="smsSender"></param>
|
|||
/// <param name="signName">短信签名</param>
|
|||
/// <param name="templateCode">短信模板号</param>
|
|||
/// <param name="phoneNumber">发送手机号</param>
|
|||
/// <param name="templateParams">短信模板参数</param>
|
|||
/// <returns></returns>
|
|||
public static async Task SendAsync(this ISmsSender smsSender, string signName, string templateCode, string phoneNumber, IDictionary<string, object> templateParams = null) |
|||
{ |
|||
var smsMessage = new SmsMessage(phoneNumber, nameof(AliyunSmsSender)); |
|||
smsMessage.Properties.Add("SignName", signName); |
|||
smsMessage.Properties.Add("TemplateCode", templateCode); |
|||
if (templateParams != null) |
|||
{ |
|||
smsMessage.Properties.AddIfNotContains(templateParams); |
|||
} |
|||
await smsSender.SendAsync(smsMessage); |
|||
} |
|||
} |
|||
} |
|||
Loading…
Reference in new issue