【问题标题】:Asp.Net Identity Store does not implement IUserEmailStore<TUser>Asp.Net Identity Store 没有实现 IUserEmailStore<TUser>
【发布时间】:2018-01-25 23:11:18
【问题描述】:

我正在探索这个身份框架,并在实现 Custome UserStore 的同时,有没有办法摆脱这些,所谓的可选接口。 根据这个线程,看起来不像一个选项。 When implementing your own IUserStore, are the "optional" interfaces on the class actually optional?

我在 .Net Framework 4.5 MVC5 上使用 2.2.1 版本

【问题讨论】:

    标签: asp.net-identity-2


    【解决方案1】:

    所以我查看了 Asp.Net.Identity 汇编代码,这是我的理解。很有可能,这对您来说可能很明显,但仍然分享:

    为了在UserManager上调用CreateAsync,默认情况下,我必须实现这些存储接口:IUserStore,IUserPasswordStore, IUserSecurityStampStore,IUserEmailStore,IUserLockoutStore .大多数对这些方法的调用都在 UserManager 中进行了模板化。

    好消息是,大​​部分UserStore调用这些接口方法都有调用前的条件,我们可以在UserManager中设置。

    例如:在 UserManager 中设置“RequireUniqueEmail=false”,在调用 CreateAsync 时不会调用 IUserEmailStore.GetEmailAsync,您不必在 UserStore 上实现它。 p>

    我为 CreateAsync 创建了地图,我认为这应该会有所帮助。

    所以,回答原始问题,如果我们知道我们要做什么 Validate(conditions),我们只能在 UserStore 上实现那些接口。

    【讨论】:

      猜你喜欢
      • 2023-03-28
      • 1970-01-01
      • 2020-02-27
      • 2016-08-20
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多