Question Details

No question body available.

Tags

asp.net-core google-authenticator google-2fa

Answers (1)

February 26, 2026 Score: 0 Rep: 11 Quality: Low Completeness: 50%

On your OnPostAsync() After validating successfully the verification code you are calling await userManager.ResetAuthenticatorKeyAsync(user); which resets the authentication key for your user, that means that the QR code previously scanned and verified by your user now has a different authentication key from what is stored.

So, even if the user activates its 2FA successfully, you changed its authentication key, and now his authenticator code is incorrect.

In summary, just remove this line from your OnPostAsync() it should look like this:

...
await userManager.SetTwoFactorEnabledAsync(user, true);
//Removed await _userManager.ResetAuthenticatorKeyAsync(user);

return RedirectToPage("./TwoFactorAuthentication");