0

I am trying to enable TwoFactor after Create user for sms code verify.

 await UserManager.SetTwoFactorEnabledAsync(user.Id, true);

This is my 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

and the problem is I need fill this two method in UserStore(SportUserStore)

  public Task SetTwoFactorEnabledAsync(T user, bool enabled)
    {
        throw new NotImplementedException();
    }

    public Task<bool> GetTwoFactorEnabledAsync(T user)
    {
        throw new NotImplementedException();
    }

Have anyone solution for this problem ?

I am using

Microsoft.AspNet.Identity.Core v2.2.2

Microsoft.AspNet.Identity.Owin v2.2.2

Alican Kablan
  • 399
  • 8
  • 17
  • I hope this link is helpful. https://stackoverflow.com/questions/25551295/custom-asp-net-identity-2-0-userstore-is-implementing-all-interfaces-required – Daniel Oliveira Oct 28 '18 at 01:15
  • No he does not use twofactor :/ Thank you anyway. – Alican Kablan Oct 28 '18 at 01:21
  • This is a good overview of [using 2FA with identify and mvc](https://learn.microsoft.com/en-us/aspnet/identity/overview/features-api/two-factor-authentication-using-sms-and-email-with-aspnet-identity). – Alex P Oct 28 '18 at 09:30

1 Answers1

0

I found the solution in 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);
}
Alican Kablan
  • 399
  • 8
  • 17