Use AuthenticatorUrl generated on the server in EnableAuthenticator pages
This commit is contained in:
parent
435ab653db
commit
ce88212f49
|
|
@ -24,7 +24,7 @@
|
|||
<p>Scan the QR Code or enter this key <kbd>@Model.SharedKey</kbd> into your two factor authenticator app. Spaces and casing do not matter.</p>
|
||||
<div class="alert alert-info">To enable QR code generation please read our <a href="https://go.microsoft.com/fwlink/?Linkid=852423">documentation</a>.</div>
|
||||
<div id="qrCode"></div>
|
||||
<div id="qrCodeData" data-url="@Html.Raw(Model.AuthenticatorUri)"></div>
|
||||
<div id="qrCodeData" data-url="@Model.AuthenticatorUri"></div>
|
||||
</li>
|
||||
<li>
|
||||
<p>
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
Loading…
Reference in New Issue