Refactor error modal into its own partial (#785)

* Refactor error modal into its own partial

* Fix unresolved error string in TwoFactorPartial

* Use tuple model instead of ViewData for error title and message

* Apply suggestions from code review
This commit is contained in:
koko 2023-06-08 00:01:59 -04:00 committed by GitHub
commit 77e46a0721
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 68 additions and 94 deletions

View file

@ -0,0 +1,8 @@
@model (string Title, string Message)
<div class="ui negative message">
<div class="header">
@Model.Title
</div>
<p style="white-space: pre-line">@Model.Message</p>
</div>

View file

@ -10,14 +10,9 @@
@Html.AntiForgeryToken()
<div class="digits" id="2fa">
@if (!string.IsNullOrWhiteSpace(error))
{
<div class="ui negative message">
<div class="header">
@Model.Translate(GeneralStrings.Error)
</div>
<p style="white-space: pre-line">@Model.Error</p>
</div>
}
{
@await Html.PartialAsync("Partials/ErrorModalPartial", ((string)Model.Translate(GeneralStrings.Error), error), ViewData)
}
<input type="text" pattern="\d*" maxlength="1" id="digit1"/>
<input type="text" pattern="\d*" maxlength="1" id="digit2"/>
<input type="text" pattern="\d*" maxlength="1" id="digit3" class="middleDigit"/>
@ -45,16 +40,16 @@
@if (allowBackupCodes)
{
<text>
document.getElementById("backup-link").addEventListener("click", function (){
let backupInput = document.getElementById("backup");
if (backupInput.style.display === "none"){
backupInput.style.display = "";
} else {
backupInput.style.display = "none";
}
});
</text>
<text>
document.getElementById("backup-link").addEventListener("click", function (){
let backupInput = document.getElementById("backup");
if (backupInput.style.display === "none"){
backupInput.style.display = "";
} else {
backupInput.style.display = "none";
}
});
</text>
}
document.querySelector(".digits").addEventListener("keydown", function(event){