diff --git a/src/UI/Areas/Identity/Pages/Account/Manage/EnableAuthenticator.cshtml b/src/UI/Areas/Identity/Pages/Account/Manage/EnableAuthenticator.cshtml index 1d68558407..9d1113d779 100644 --- a/src/UI/Areas/Identity/Pages/Account/Manage/EnableAuthenticator.cshtml +++ b/src/UI/Areas/Identity/Pages/Account/Manage/EnableAuthenticator.cshtml @@ -24,7 +24,7 @@
Scan the QR Code or enter this key @Model.SharedKey into your two factor authenticator app. Spaces and casing do not matter.
diff --git a/src/UI/Areas/Identity/Pages/Account/Manage/EnableAuthenticator.cshtml.cs b/src/UI/Areas/Identity/Pages/Account/Manage/EnableAuthenticator.cshtml.cs index 0d564584a4..ee507fc299 100644 --- a/src/UI/Areas/Identity/Pages/Account/Manage/EnableAuthenticator.cshtml.cs +++ b/src/UI/Areas/Identity/Pages/Account/Manage/EnableAuthenticator.cshtml.cs @@ -55,11 +55,6 @@ namespace Microsoft.AspNetCore.Identity.UI.Pages.Account.Manage } await LoadSharedKeyAndQrCodeUriAsync(user); - if (string.IsNullOrEmpty(SharedKey)) - { - await _userManager.ResetAuthenticatorKeyAsync(user); - await LoadSharedKeyAndQrCodeUriAsync(user); - } return Page(); } @@ -100,11 +95,14 @@ namespace Microsoft.AspNetCore.Identity.UI.Pages.Account.Manage { // Load the authenticator key & QR code URI to display on the form var unformattedKey = await _userManager.GetAuthenticatorKeyAsync(user); - if (!string.IsNullOrEmpty(unformattedKey)) + if (string.IsNullOrEmpty(unformattedKey)) { - SharedKey = FormatKey(unformattedKey); - AuthenticatorUri = GenerateQrCodeUri(user.Email, unformattedKey); + await _userManager.ResetAuthenticatorKeyAsync(user); + unformattedKey = await _userManager.GetAuthenticatorKeyAsync(user); } + + SharedKey = FormatKey(unformattedKey); + AuthenticatorUri = GenerateQrCodeUri(user.Email, unformattedKey); } private string FormatKey(string unformattedKey)