问题描述
我创建了一个自定义的 IUserStore< TUSER,INT>
我的应用程序。我实现了我所需要的接口,
I've created a custom IUserStore<TUser,int>
for my application. I've implemented the interfaces I need,
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);
我得到一个异常说
I get an exception saying
Store does not implement IUserTwoFactorStore<TUser>.
我没有在我的应用程序中使用双因素认证的任何地方。为什么会期待我实现该接口?需要它,我实现了所有这些接口的,即使我不实际使用他们?
I'm not using two factor authentication anywhere in my application. Why does it expect me to implement that interface? Is it required that I implement all of these interfaces, even if I don't actually use them?
推荐答案
其实, IUserTwoFactorStore
界面非常简单的,到目前为止,我实现(我不使用双因素AUTH其一)是这样的:
Actually the IUserTwoFactorStore
interface is really simple, so far my implementation (I don't use two factor auth either) is this:
....
public Task<bool> GetTwoFactorEnabledAsync(User user)
{
return Task.FromResult(false);
}
public Task SetTwoFactorEnabledAsync(User user, bool enabled)
{
throw new NotImplementedException();
}
它的工作原理,但我只是没有几分钟前,并没有彻底测试整个应用程序。
It works, although I just did it couple minutes ago and didn't test whole app thoroughly.
这篇关于自定义ASP.NET身份2.0 UserStore - 正在实施的所有接口要求?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!