在使用Abp框架的时候,有时候会需要在登录验证处处理一些特殊的业务。
例如判断是否账号是否在某一特殊状态。
经过查看Abp密码验证模式源码,没有发现预留的接口能够插入自己的业务。只有一个IExternalLoginProvider
接口接外部登录使用的。
查看AbpIdentityServer
模块,AddAbpIdentityServer扩展方法。
这样,咱们直接继承AbpResourceOwnerPasswordValidator
,然后在自己模块的PreConfigureServices
里面直接注入就行了。
新建AbpReplaceResourceOwnerPasswordValidator
继承于AbpResourceOwnerPasswordValidator
在自己的模块中,使用PreConfigure<IIdentityServerBuilder>
注入AbpReplaceResourceOwnerPasswordValidator
public class XXDomainModule : AbpModule
{
public override void PreConfigureServices(ServiceConfigurationContext context)
{
PreConfigure<IIdentityServerBuilder>(options =>
{
options.AddResourceOwnerValidator<AbpReplaceResourceOwnerPasswordValidator>();
});
}
}