Privacy-first password manager with built-in email aliasing. Fully encrypted and self-hostable.
Add missing translations for login and other client forms (#1153)
Leendert de Borstef72abceb4e7
diff --git a/apps/server/AliasVault.Client/Auth/Models/LoginFormModel.cs b/apps/server/AliasVault.Client/Auth/Models/LoginFormModel.csnew file mode 100644index 000000000..f2b868e96--- /dev/null+++ b/apps/server/AliasVault.Client/Auth/Models/LoginFormModel.cs@@ -0,0 +1,44 @@+//-----------------------------------------------------------------------+// <copyright file="LoginFormModel.cs" company="lanedirt">+// Copyright (c) lanedirt. All rights reserved.+// Licensed under the AGPLv3 license. See LICENSE.md file in the project root for full license information.+// </copyright>+//-----------------------------------------------------------------------++namespace AliasVault.Client.Auth.Models;++using System.ComponentModel.DataAnnotations;+using AliasVault.Client.Resources;+using AliasVault.Shared.Models.WebApi.Auth;++/// <summary>+/// Login form model with localized validation.+/// </summary>+public class LoginFormModel : LoginModel+{+ /// <summary>+ /// Gets or sets the username.+ /// </summary>+ [Required(ErrorMessageResourceType = typeof(ValidationMessages), ErrorMessageResourceName = nameof(ValidationMessages.UsernameRequired))]+ public new string Username { get; set; } = null!;++ /// <summary>+ /// Gets or sets the password.+ /// </summary>+ [Required(ErrorMessageResourceType = typeof(ValidationMessages), ErrorMessageResourceName = nameof(ValidationMessages.PasswordRequired))]+ public new string Password { get; set; } = null!;++ /// <summary>+ /// Converts the form model to the base model.+ /// </summary>+ /// <returns>The base LoginModel.</returns>+ public LoginModel ToBaseModel()+ {+ return new LoginModel+ {+ Username = Username,+ Password = Password,+ RememberMe = RememberMe,+ };+ }+}diff --git a/apps/server/AliasVault.Client/Auth/Models/RegisterFormModel.cs b/apps/server/AliasVault.Client/Auth/Models/RegisterFormModel.csindex 42bccb869..49cd025ee 100644--- a/apps/server/AliasVault.Client/Auth/Models/RegisterFormModel.cs+++ b/apps/server/AliasVault.Client/Auth/Models/RegisterFormModel.cs@@ -20,20 +20,20 @@ public class RegisterFormModel : RegisterModel/// <summary>/// Gets or sets the username./// </summary>- [Required]+ [Required(ErrorMessageResourceType = typeof(ValidationMessages), ErrorMessageResourceName = nameof(ValidationMessages.UsernameRequired))]public new string Username { get; set; } = null!;/// <summary>/// Gets or sets the password./// </summary>- [Required]+ [Required(ErrorMessageResourceType = typeof(ValidationMessages), ErrorMessageResourceName = nameof(ValidationMessages.PasswordRequired))][MinLength(8, ErrorMessageResourceType = typeof(ValidationMessages), ErrorMessageResourceName = nameof(ValidationMessages.PasswordMinLengthGeneric))]public new string Password { get; set; } = null!;/// <summary>/// Gets or sets the password confirmation./// </summary>- [Required]+ [Required(ErrorMessageResourceType = typeof(ValidationMessages), ErrorMessageResourceName = nameof(ValidationMessages.PasswordRequired))][Compare("Password", ErrorMessageResourceType = typeof(ValidationMessages), ErrorMessageResourceName = nameof(ValidationMessages.PasswordsDoNotMatchGeneric))]public new string PasswordConfirm { get; set; } = null!;diff --git a/apps/server/AliasVault.Client/Auth/Pages/Login.razor b/apps/server/AliasVault.Client/Auth/Pages/Login.razorindex 4639d58cd..8f54fa8bc 100644--- a/apps/server/AliasVault.Client/Auth/Pages/Login.razor+++ b/apps/server/AliasVault.Client/Auth/Pages/Login.razor@@ -6,6 +6,7 @@@using System.Text.Json@using AliasVault.Shared.Models.WebApi.Auth@using AliasVault.Client.Auth.Components+@using AliasVault.Client.Auth.Models@using AliasVault.Client.Utilities@using AliasVault.Cryptography.Client@using SecureRemotePassword@@ -118,7 +119,7 @@ else}@code {- private readonly LoginModel _loginModel = new();+ private readonly LoginFormModel _loginModel = new();private readonly LoginModel2Fa _loginModel2Fa = new();private readonly LoginModelRecoveryCode _loginModelRecoveryCode = new();private FullScreenLoadingIndicator _loadingIndicator = new();diff --git a/apps/server/AliasVault.Client/Main/Models/CredentialEdit.cs b/apps/server/AliasVault.Client/Main/Models/CredentialEdit.csindex 6ca0d5434..923e9c081 100644--- a/apps/server/AliasVault.Client/Main/Models/CredentialEdit.cs+++ b/apps/server/AliasVault.Client/Main/Models/CredentialEdit.cs@@ -15,6 +15,7 @@ using System.Text.Json;using System.Text.Json.Serialization;using AliasClientDb;using AliasVault.Client.Main.Models.FormValidation;+using AliasVault.Client.Resources;/// <summary>/// Credential edit model.@@ -39,7 +40,7 @@ public sealed class CredentialEdit/// <summary>/// Gets or sets the name of the service./// </summary>- [Required]+ [Required(ErrorMessageResourceType = typeof(ValidationMessages), ErrorMessageResourceName = nameof(ValidationMessages.ServiceNameRequired))][Display(Name = "Service Name")]public string ServiceName { get; set; } = string.Empty;diff --git a/apps/server/AliasVault.Client/Main/Models/Validation/PasswordChangeFormModel.cs b/apps/server/AliasVault.Client/Main/Models/Validation/PasswordChangeFormModel.csindex 6d85f1b31..765407abd 100644--- a/apps/server/AliasVault.Client/Main/Models/Validation/PasswordChangeFormModel.cs+++ b/apps/server/AliasVault.Client/Main/Models/Validation/PasswordChangeFormModel.cs@@ -19,20 +19,20 @@ public class PasswordChangeFormModel : PasswordChangeModel/// <summary>/// Gets or sets the current password./// </summary>- [Required]+ [Required(ErrorMessageResourceType = typeof(ValidationMessages), ErrorMessageResourceName = nameof(ValidationMessages.PasswordRequired))]public new string CurrentPassword { get; set; } = null!;/// <summary>/// Gets or sets the new password./// </summary>- [Required]+ [Required(ErrorMessageResourceType = typeof(ValidationMessages), ErrorMessageResourceName = nameof(ValidationMessages.PasswordRequired))][MinLength(10, ErrorMessageResourceType = typeof(ValidationMessages), ErrorMessageResourceName = nameof(ValidationMessages.PasswordMinLength))]public new string NewPassword { get; set; } = null!;/// <summary>/// Gets or sets the password confirmation./// </summary>- [Required]+ [Required(ErrorMessageResourceType = typeof(ValidationMessages), ErrorMessageResourceName = nameof(ValidationMessages.PasswordRequired))][Compare("NewPassword", ErrorMessageResourceType = typeof(ValidationMessages), ErrorMessageResourceName = nameof(ValidationMessages.PasswordsDoNotMatch))]public new string NewPasswordConfirm { get; set; } = null!;diff --git a/apps/server/AliasVault.Client/Resources/ValidationMessages.cs b/apps/server/AliasVault.Client/Resources/ValidationMessages.csindex e21bdcc55..9fc16c86f 100644--- a/apps/server/AliasVault.Client/Resources/ValidationMessages.cs+++ b/apps/server/AliasVault.Client/Resources/ValidationMessages.cs@@ -60,6 +60,16 @@ public static class ValidationMessages/// </summary>public static string MustAcceptTerms => GetResourceValue("MustAcceptTerms");+ /// <summary>+ /// Gets the error message when service name is required.+ /// </summary>+ public static string ServiceNameRequired => GetResourceValue("ServiceNameRequired");++ /// <summary>+ /// Gets the generic error message when a field is required.+ /// </summary>+ public static string FieldRequired => GetResourceValue("FieldRequired");+/// <summary>/// Gets the resource value for the specified key./// </summary>diff --git a/apps/server/AliasVault.Client/Resources/ValidationMessages.en.resx b/apps/server/AliasVault.Client/Resources/ValidationMessages.en.resxindex b6309c8f3..d813bd1e6 100644--- a/apps/server/AliasVault.Client/Resources/ValidationMessages.en.resx+++ b/apps/server/AliasVault.Client/Resources/ValidationMessages.en.resx@@ -90,6 +90,14 @@<value>Secret key is required</value><comment>Error message when secret key is required</comment></data>+ <data name="ServiceNameRequired" xml:space="preserve">+ <value>Service name is required</value>+ <comment>Error message when service name is required</comment>+ </data>+ <data name="FieldRequired" xml:space="preserve">+ <value>This field is required</value>+ <comment>Generic error message when a field is required</comment>+ </data><!-- Terms and conditions --><data name="MustAcceptTerms" xml:space="preserve">