Merge pull request #123 from LD-Reborn/122-bug-login-page-invalid-login-credentials-not-localized

Fixed localization for /Home/Login
This commit is contained in:
LD50
2025-10-12 20:19:10 +02:00
committed by GitHub
3 changed files with 18 additions and 5 deletions

View File

@@ -129,14 +129,14 @@ public class HomeController : Controller
switch (authenticationResult.AuthenticationState)
{
case UserNotAuthenticatedReason.InvalidCredentials:
return View(new LoginViewModel() { ErrorText = "Invalid login credentials" }); // TODO add localization (e.g. T["Invalid login credentials"]; see: https://learn.microsoft.com/de-de/dotnet/core/extensions/localization)
return View(new LoginViewModel() { ErrorText = "Invalid login credentials" });
case UserNotAuthenticatedReason.UserLockedOut:
return View(new LoginViewModel() { ErrorText = "Your account has been locked. Wait a few minutes or ask an administrator to unlock you" }); // TODO add localization (e.g. T["Invalid login credentials"]; see: https://learn.microsoft.com/de-de/dotnet/core/extensions/localization)
return View(new LoginViewModel() { ErrorText = "Your account has been locked. Wait a few minutes or ask an administrator to unlock you" });
case UserNotAuthenticatedReason.UserNotAuthorized:
return View(new LoginViewModel() { ErrorText = "You are not authorized for login. Ask an administrator to authorize you." }); // TODO add localization (e.g. T["Invalid login credentials"]; see: https://learn.microsoft.com/de-de/dotnet/core/extensions/localization)
return View(new LoginViewModel() { ErrorText = "You are not authorized for login. Ask an administrator to authorize you." });
default:
await HttpContext.RaiseError(new HellFrozeOverException());
return View(new LoginViewModel() { ErrorText = "Hell froze over. Make a screenshot and send it to an administrator." }); // TODO add localization (e.g. T["Invalid login credentials"]; see: https://learn.microsoft.com/de-de/dotnet/core/extensions/localization)
return View(new LoginViewModel() { ErrorText = "Hell froze over. Make a screenshot and send it to an administrator." });
}
}

View File

@@ -25,4 +25,16 @@
<data name="Password" xml:space="preserve">
<value>Passwort</value>
</data>
<data name="Invalid login credentials" xml:space="preserve">
<value>Ungültige Anmeldedaten</value>
</data>
<data name="Your account has been locked. Wait a few minutes or ask an administrator to unlock you" xml:space="preserve">
<value>Ihr Konto wurde gesperrt. Warten Sie einige Minuten oder bitten Sie einen Administrator, die Sperre aufzuheben.</value>
</data>
<data name="You are not authorized for login. Ask an administrator to authorize you." xml:space="preserve">
<value>Sie sind nicht zur Anmeldung berechtigt. Bitten Sie einen Administrator, Ihnen die Berechtigung zu erteilen.</value>
</data>
<data name="Hell froze over. Make a screenshot and send it to an administrator." xml:space="preserve">
<value>Die Hölle ist zugefroren. Machen Sie einen Screenshot und senden Sie ihn an einen Administrator.</value>
</data>
</root>

View File

@@ -1,4 +1,5 @@
@using Microsoft.AspNetCore.Mvc.Localization
@model LoginViewModel
@inject IViewLocalizer T
@{
ViewData["Title"] = T["Login"];
@@ -10,7 +11,7 @@
if (Model.ErrorText is not null)
{
<div class="alert alert-danger text-center login-error">
<h2>@Model.ErrorText</h2>
<h2>@T[Model.ErrorText]</h2>
</div>
}
}