在创建用于短信验证的用户之后,我试图启用TwoFactor。
await UserManager.SetTwoFactorEnabledAsync(user.Id, true);
这是我的UserStore(SportUserStore):
public class SportUserStore<T> : IUserPasswordStore<T>, IUserSecurityStampStore<T>, IUserTwoFactorStore<T, string>,
IUserRoleStore<T>, IUserLoginStore<T>, IUserPhoneNumberStore<T>, IUserEmailStore<T>, IUserStore<T> where T : FrUser
问题是我需要在UserStore(SportUserStore)中填充这两种方法
public Task SetTwoFactorEnabledAsync(T user, bool enabled)
{
throw new NotImplementedException();
}
public Task<bool> GetTwoFactorEnabledAsync(T user)
{
throw new NotImplementedException();
}
有人对此问题有解决方案吗?
我正在使用
Microsoft.AspNet.Identity.Core v2.2.2
Microsoft.AspNet.Identity.Owin v2.2.2
答案 0 :(得分:0)
我在Identity.EntityFramework中找到了解决方案
public virtual Task SetTwoFactorEnabledAsync(TUser user, bool enabled)
{
this.ThrowIfDisposed();
if ((object) user == null)
throw new ArgumentNullException(nameof (user));
user.TwoFactorEnabled = enabled;
return (Task) Task.FromResult<int>(0);
}
public virtual Task<bool> GetTwoFactorEnabledAsync(TUser user)
{
this.ThrowIfDisposed();
if ((object) user == null)
throw new ArgumentNullException(nameof (user));
return Task.FromResult<bool>(user.TwoFactorEnabled);
}