我创建了一个自定义 IUserStore<TUser,int>
为我的申请。我已经实现了我需要的接口(interface),
IUserStore<TUser, int>,
IUserRoleStore<TUser, int>,
IUserLockoutStore<TUser, int>,
IUserPasswordStore<TUser, int>
但是当我打电话的时候
var result = await SignInManager.PasswordSignInAsync(model.UserName, model.Password, model.RememberMe, shouldLockout: false);
我得到一个异常(exception)说
Store does not implement IUserTwoFactorStore<TUser>.
我没有在我的应用程序中的任何地方使用双因素身份验证。为什么它希望我实现该接口(interface)?是否需要我实现所有这些接口(interface),即使我实际上并不使用它们?
最佳答案
实际上 IUserTwoFactorStore
接口(interface)非常简单,到目前为止我的实现(我也不使用双因素身份验证)是这样的:
....
public Task<bool> GetTwoFactorEnabledAsync(User user)
{
return Task.FromResult(false);
}
public Task SetTwoFactorEnabledAsync(User user, bool enabled)
{
throw new NotImplementedException();
}
虽然我几分钟前刚刚做过,但没有彻底测试整个应用程序,但它确实有效。
关于c# - 自定义 ASP.NET Identity 2.0 UserStore - 是否需要实现所有接口(interface)?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25551295/