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>
|
<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 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="qrCode"></div>
|
||||||
<div id="qrCodeData" data-url="@Html.Raw(Model.AuthenticatorUri)"></div>
|
<div id="qrCodeData" data-url="@Model.AuthenticatorUri"></div>
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li>
|
||||||
<p>
|
<p>
|
||||||
|
|
|
||||||
|
|
@ -55,11 +55,6 @@ namespace Microsoft.AspNetCore.Identity.UI.Pages.Account.Manage
|
||||||
}
|
}
|
||||||
|
|
||||||
await LoadSharedKeyAndQrCodeUriAsync(user);
|
await LoadSharedKeyAndQrCodeUriAsync(user);
|
||||||
if (string.IsNullOrEmpty(SharedKey))
|
|
||||||
{
|
|
||||||
await _userManager.ResetAuthenticatorKeyAsync(user);
|
|
||||||
await LoadSharedKeyAndQrCodeUriAsync(user);
|
|
||||||
}
|
|
||||||
|
|
||||||
return Page();
|
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
|
// Load the authenticator key & QR code URI to display on the form
|
||||||
var unformattedKey = await _userManager.GetAuthenticatorKeyAsync(user);
|
var unformattedKey = await _userManager.GetAuthenticatorKeyAsync(user);
|
||||||
if (!string.IsNullOrEmpty(unformattedKey))
|
if (string.IsNullOrEmpty(unformattedKey))
|
||||||
{
|
{
|
||||||
SharedKey = FormatKey(unformattedKey);
|
await _userManager.ResetAuthenticatorKeyAsync(user);
|
||||||
AuthenticatorUri = GenerateQrCodeUri(user.Email, unformattedKey);
|
unformattedKey = await _userManager.GetAuthenticatorKeyAsync(user);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SharedKey = FormatKey(unformattedKey);
|
||||||
|
AuthenticatorUri = GenerateQrCodeUri(user.Email, unformattedKey);
|
||||||
}
|
}
|
||||||
|
|
||||||
private string FormatKey(string unformattedKey)
|
private string FormatKey(string unformattedKey)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue