fix: prevent login JS crash when returnUrl is empty

Replace eval-built form submit with tsaLogin.submitForm so a missing returnUrl no longer produces invalid JavaScript.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
2026-08-14 15:19:11 -04:00
co-authored by Cursor
parent afdabd179a
commit 980a7213a4
3 changed files with 38 additions and 10 deletions
@@ -134,7 +134,7 @@
if (e.Key == "Enter")
{
// Blur the active element to ensure MudTextField bindings update
await JS.InvokeVoidAsync("eval", "document.activeElement.blur()");
await JS.InvokeVoidAsync("tsaLogin.blurActiveElement");
// Small delay to allow bindings to process
await Task.Delay(50);
@@ -146,14 +146,11 @@
private async Task HandleFormSubmit()
{
// Update hidden inputs with current model values, then submit the form
var returnUrlValue = string.IsNullOrEmpty(_returnUrl) ? "" : System.Text.Json.JsonSerializer.Serialize(_returnUrl);
await JS.InvokeVoidAsync("eval", $@"
document.getElementById('emailInput').value = {System.Text.Json.JsonSerializer.Serialize(_loginModel.Email)};
document.getElementById('passwordInput').value = {System.Text.Json.JsonSerializer.Serialize(_loginModel.Password)};
document.getElementById('rememberMeInput').value = '{_loginModel.RememberMe.ToString().ToLower()}';
document.getElementById('returnUrlInput').value = {returnUrlValue};
document.getElementById('loginForm').submit();
");
await JS.InvokeVoidAsync(
"tsaLogin.submitForm",
_loginModel.Email ?? string.Empty,
_loginModel.Password ?? string.Empty,
_loginModel.RememberMe,
_returnUrl ?? string.Empty);
}
}