You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have created a custom google authenticator token provider implementing IUserTwoFactorTokenProvider. but I'm not sure where and how do I register this new provider in Startup?
public class GoogleAuthenticatorTokenProvider : IUserTwoFactorTokenProvider<User>
{
public GoogleAuthenticatorTokenProvider()
{
}
public Task<bool> CanGenerateTwoFactorTokenAsync(UserManager<User> manager, User user)
{
return Task.FromResult(user.IsGoogleAuthenticatorEnabled);
}
public Task<string> GenerateAsync(string purpose, UserManager<User> manager, User user)
{
return Task.FromResult((string)null);
}
public Task<bool> ValidateAsync(string purpose, string token, UserManager<User> manager, User user)
{
long timeStepMatched = 0;
var otp = new Totp(WebEncoders.Base64UrlDecode(user.GoogleAuthenticatorSecretKey));
bool valid = otp.VerifyTotp(token, out timeStepMatched, new VerificationWindow(2, 2));
return Task.FromResult(valid);
}
}
The text was updated successfully, but these errors were encountered:
I have created a custom google authenticator token provider implementing IUserTwoFactorTokenProvider. but I'm not sure where and how do I register this new provider in Startup?
The text was updated successfully, but these errors were encountered: