TwoFactorAuthentication.cshtml 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. @page
  2. @using Microsoft.AspNetCore.Http.Features
  3. @model TwoFactorAuthenticationModel
  4. @{
  5. ViewData["Title"] = "Two-factor authentication (2FA)";
  6. ViewData["ActivePage"] = ManageNavPages.TwoFactorAuthentication;
  7. }
  8. <partial name="_StatusMessage" for="StatusMessage" />
  9. <h3>@ViewData["Title"]</h3>
  10. @{
  11. var consentFeature = HttpContext.Features.Get<ITrackingConsentFeature>();
  12. @if (consentFeature?.CanTrack ?? true)
  13. {
  14. @if (Model.Is2faEnabled)
  15. {
  16. if (Model.RecoveryCodesLeft == 0)
  17. {
  18. <div class="alert alert-danger">
  19. <strong>You have no recovery codes left.</strong>
  20. <p>You must <a asp-page="./GenerateRecoveryCodes">generate a new set of recovery codes</a> before you can log in with a recovery code.</p>
  21. </div>
  22. }
  23. else if (Model.RecoveryCodesLeft == 1)
  24. {
  25. <div class="alert alert-danger">
  26. <strong>You have 1 recovery code left.</strong>
  27. <p>You can <a asp-page="./GenerateRecoveryCodes">generate a new set of recovery codes</a>.</p>
  28. </div>
  29. }
  30. else if (Model.RecoveryCodesLeft <= 3)
  31. {
  32. <div class="alert alert-warning">
  33. <strong>You have @Model.RecoveryCodesLeft recovery codes left.</strong>
  34. <p>You should <a asp-page="./GenerateRecoveryCodes">generate a new set of recovery codes</a>.</p>
  35. </div>
  36. }
  37. if (Model.IsMachineRemembered)
  38. {
  39. <form method="post" style="display: inline-block">
  40. <button type="submit" class="btn btn-primary">Forget this browser</button>
  41. </form>
  42. }
  43. <a asp-page="./Disable2fa" class="btn btn-primary">Disable 2FA</a>
  44. <a asp-page="./GenerateRecoveryCodes" class="btn btn-primary">Reset recovery codes</a>
  45. }
  46. <h4>Authenticator app</h4>
  47. @if (!Model.HasAuthenticator)
  48. {
  49. <a id="enable-authenticator" asp-page="./EnableAuthenticator" class="btn btn-primary">Add authenticator app</a>
  50. }
  51. else
  52. {
  53. <a id="enable-authenticator" asp-page="./EnableAuthenticator" class="btn btn-primary">Set up authenticator app</a>
  54. <a id="reset-authenticator" asp-page="./ResetAuthenticator" class="btn btn-primary">Reset authenticator app</a>
  55. }
  56. }
  57. else
  58. {
  59. <div class="alert alert-danger">
  60. <strong>Privacy and cookie policy have not been accepted.</strong>
  61. <p>You must accept the policy before you can enable two factor authentication.</p>
  62. </div>
  63. }
  64. }
  65. @section Scripts {
  66. <partial name="_ValidationScriptsPartial" />
  67. }