在使用Abp框架的时候,有时候会需要在登录验证处处理一些特殊的业务。
    例如判断是否账号是否在某一特殊状态。

    经过查看Abp密码验证模式源码,没有发现预留的接口能够插入自己的业务。只有一个IExternalLoginProvider接口接外部登录使用的。

    查看AbpIdentityServer模块,AddAbpIdentityServer扩展方法
    image.png
    这样,咱们直接继承AbpResourceOwnerPasswordValidator,然后在自己模块的PreConfigureServices里面直接注入就行了。

    新建AbpReplaceResourceOwnerPasswordValidator继承于AbpResourceOwnerPasswordValidator
    image.png
    在自己的模块中,使用PreConfigure<IIdentityServerBuilder>注入AbpReplaceResourceOwnerPasswordValidator

    1. public class XXDomainModule : AbpModule
    2. {
    3. public override void PreConfigureServices(ServiceConfigurationContext context)
    4. {
    5. PreConfigure<IIdentityServerBuilder>(options =>
    6. {
    7. options.AddResourceOwnerValidator<AbpReplaceResourceOwnerPasswordValidator>();
    8. });
    9. }
    10. }