feat: application shell, localized texts and user preferences (M3, part 1)
The pages built so far now live inside the shell of the mockups instead of the M0 placeholder, every interface text comes from Resources/it-IT, and each user keeps their own look and start page. - Shell: top bar, collapsible side menu with fly-out sub-menus, status bar and tabs that keep each page alive (page type and route values per tab, so a tab never shows another page); at most 12 tabs, least-used clean tab evicted. - One shortcut table with Alt variants for the combinations browsers keep (Ctrl+W, Ctrl+Tab, Ctrl+N); command palette for pages and commands. - ITexts over embedded JSON; tests forbid literal texts in .razor components and check that every key used exists. - User settings in sys_user_settings / user_settings; theme written on the server; profile page with live preview, start page, sessions and shortcuts. - Home, coming-soon pages for later milestones, localized sign-in and error pages; ADR 0020; wiki, CHANGELOG, STATUS and data model updated. Refs #25 #26 #31 #33 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
1c30054e3d
commit
cf6f849cc1
72 files changed
+5785
-259
No files matched your search
@@ -1,3 +1,4 @@
|
||||
using Khaemhat.Application.Localization;
|
||||
using Khaemhat.Application.Security;
|
||||
using Khaemhat.Core.Security;
|
||||
|
||||
@@ -40,30 +41,25 @@ public static class LoginFlow
|
||||
? url
|
||||
: "/";
|
||||
|
||||
/// <summary>The Italian message of an error code (several codes may be joined by commas).</summary>
|
||||
/// <summary>The messages of error codes (several codes may be joined by commas), from the texts <c>Auth.Errors.*</c>.</summary>
|
||||
/// <param name="texts">The texts.</param>
|
||||
/// <param name="policy">The password policy, for the numbers in the messages.</param>
|
||||
/// <param name="error">The code(s).</param>
|
||||
/// <returns>The messages.</returns>
|
||||
public static IReadOnlyList<string> Messages(string? error) =>
|
||||
string.IsNullOrEmpty(error) ? [] : [.. error.Split(',', StringSplitOptions.RemoveEmptyEntries | StringSplitOptions.TrimEntries).Select(Message)];
|
||||
|
||||
private static string Message(string code) => code switch
|
||||
public static IReadOnlyList<string> Messages(ITexts texts, SecurityPolicyOptions policy, string? error)
|
||||
{
|
||||
SecurityErrors.InvalidCredentials => "Azienda, utente o password non corretti.",
|
||||
SecurityErrors.AccountLocked => "Troppi tentativi non riusciti: l'account è bloccato per 15 minuti.",
|
||||
SecurityErrors.AccountDisabled => "L'account è disattivato: rivolgiti all'amministratore.",
|
||||
SecurityErrors.TemporaryPasswordExpired => "La password provvisoria è scaduta: chiedine una nuova all'amministratore.",
|
||||
SecurityErrors.PasswordTooShort => "La nuova password è troppo corta: servono almeno 10 caratteri.",
|
||||
SecurityErrors.PasswordTooSimple => "La nuova password deve contenere almeno tre tipi di carattere tra minuscole, maiuscole, cifre e simboli.",
|
||||
SecurityErrors.PasswordContainsUserName => "La nuova password non può contenere il nome utente.",
|
||||
SecurityErrors.PasswordReused => "La nuova password è uguale a una delle ultime cinque.",
|
||||
SecurityErrors.CurrentPasswordWrong => "La password attuale non è corretta.",
|
||||
SecurityErrors.TotpInvalid => "Codice non valido: controlla l'ora del telefono e riprova.",
|
||||
SecurityErrors.RateLimited => "Troppi tentativi: riprova tra un minuto.",
|
||||
SecurityErrors.ConcurrentUsersExceeded => "È stato raggiunto il numero massimo di utenti collegati previsto dalla licenza.",
|
||||
SecurityErrors.CompanyUnavailable => "L'azienda è in manutenzione o non è disponibile.",
|
||||
SecurityErrors.LicenseLimitReached => "La licenza non consente altri accessi di questo tipo.",
|
||||
_ => "Accesso non riuscito.",
|
||||
};
|
||||
ArgumentNullException.ThrowIfNull(texts);
|
||||
ArgumentNullException.ThrowIfNull(policy);
|
||||
return string.IsNullOrEmpty(error)
|
||||
? []
|
||||
: [.. error.Split(',', StringSplitOptions.RemoveEmptyEntries | StringSplitOptions.TrimEntries).Select(code => Message(texts, policy, code))];
|
||||
}
|
||||
|
||||
private static string Message(ITexts texts, SecurityPolicyOptions policy, string code)
|
||||
{
|
||||
var key = "Auth.Errors." + code;
|
||||
return texts.Contains(key) ? texts.Format(key, policy.MinimumLength, policy.HistorySize) : texts["Auth.Errors.Other"];
|
||||
}
|
||||
|
||||
private static string Carry(string? returnUrl) =>
|
||||
SafeReturnUrl(returnUrl) is var url && url != "/" ? "?returnUrl=" + Uri.EscapeDataString(url) : string.Empty;
|
||||
|
||||
Reference in new issue
Block a user