diff --git a/Yavsc/Attributes/Validation/RequiredAttribute.cs b/Yavsc/Attributes/Validation/RequiredAttribute.cs
new file mode 100644
index 00000000..2ae3adc4
--- /dev/null
+++ b/Yavsc/Attributes/Validation/RequiredAttribute.cs
@@ -0,0 +1,58 @@
+using System;
+
+namespace Yavsc.Attributes.Validation
+{
+ public class YaValidationAttribute : System.ComponentModel.DataAnnotations.ValidationAttribute
+ {
+ public YaValidationAttribute() : base(()=> Startup.GlobalLocalizer["validationError"])
+ {
+
+ }
+ public override string FormatErrorMessage(string name)
+ {
+ return Startup.GlobalLocalizer[name];
+ }
+ }
+
+ [AttributeUsage(AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Parameter, AllowMultiple = false)]
+ public class YaRequiredAttribute : YaValidationAttribute
+ {
+
+ ///
+ /// Gets or sets a flag indicating whether the attribute should allow empty strings.
+ ///
+ public bool AllowEmptyStrings { get; set; }
+ public YaRequiredAttribute (string msg) : base()
+ {
+ ErrorMessage = msg;
+ }
+ public YaRequiredAttribute ()
+ {
+ this.ErrorMessage = Startup.GlobalLocalizer["RequiredField"];
+
+ }
+ public override bool IsValid(object value) {
+ if (value == null) {
+ return false;
+ }
+
+ // only check string length if empty strings are not allowed
+ var stringValue = value as string;
+ if (stringValue != null && !AllowEmptyStrings) {
+ return stringValue.Trim().Length != 0;
+ }
+
+ return true;
+ }
+ }
+ public class YaRegularExpression : System.ComponentModel.DataAnnotations.RegularExpressionAttribute {
+ public YaRegularExpression(string pattern): base (pattern)
+ {
+ this.ErrorMessage = pattern;
+ }
+ public override string FormatErrorMessage(string name)
+ {
+ return Startup.GlobalLocalizer[name];
+ }
+ }
+}
\ No newline at end of file
diff --git a/Yavsc/Controllers/AccountController.cs b/Yavsc/Controllers/AccountController.cs
index 68ed1cc5..0cadcc73 100644
--- a/Yavsc/Controllers/AccountController.cs
+++ b/Yavsc/Controllers/AccountController.cs
@@ -626,7 +626,7 @@ namespace Yavsc.Controllers
{
foreach (var error in result.Errors)
{
- ModelState.AddModelError(string.Empty, error.Description);
+ ModelState.AddModelError(string.Empty, _localizer[ error.Code ]);
}
}
diff --git a/Yavsc/Resources/Yavsc.Resources.YavscLocalisation.en.resx b/Yavsc/Resources/Yavsc.Resources.YavscLocalisation.en.resx
index 898df4d7..91d34787 100644
--- a/Yavsc/Resources/Yavsc.Resources.YavscLocalisation.en.resx
+++ b/Yavsc/Resources/Yavsc.Resources.YavscLocalisation.en.resx
@@ -341,4 +341,10 @@ contact a performer
Hair Length
French
English
+ This field is required.
+ Passwords must be at least {0} characters.
+ Passwords must have at least one non letter and non digit character.
+ Passwords must have at least one digit ('0'-'9').
+ Passwords must have at least one uppercase ('A'-'Z').
+
diff --git a/Yavsc/Resources/Yavsc.Resources.YavscLocalisation.fr.resx b/Yavsc/Resources/Yavsc.Resources.YavscLocalisation.fr.resx
index 21aabd52..3fcddb02 100644
--- a/Yavsc/Resources/Yavsc.Resources.YavscLocalisation.fr.resx
+++ b/Yavsc/Resources/Yavsc.Resources.YavscLocalisation.fr.resx
@@ -437,4 +437,13 @@
Supprimer mon profil professionel
Français
Anglais
+ Nom d'utilisateur invalide.
+ Les valides sont: le souligné '_', le titret '-', de 'a' à 'z', de 'A' à 'Z', de 0 à 9, l'espace et le point.
+ Ce champ est obligatoire.
+ Champ invalide ...
+ Le Mot de passe doit contenir au moins 6 caractères.
+ Mot de passe doit contenir au moins a caractère spécial (ni un chiffre, ni une lettre).
+ Les mots de passe doivent contenir au moins un chiffre ('0' à '9').
+ Les mots de passe doivent contenir au moins une lettre majuscule ('A' à 'Z').
+
diff --git a/Yavsc/ViewModels/Account/RegisterViewModel.cs b/Yavsc/ViewModels/Account/RegisterViewModel.cs
index c890f224..a5cfdad6 100644
--- a/Yavsc/ViewModels/Account/RegisterViewModel.cs
+++ b/Yavsc/ViewModels/Account/RegisterViewModel.cs
@@ -1,24 +1,32 @@
using System.ComponentModel.DataAnnotations;
+using Yavsc.Attributes.Validation;
namespace Yavsc.ViewModels.Account
{
public class RegisterViewModel
{
- [Required][Display(Name = "Nom d'utilisateur")]
+ // ErrorMessage = "",
+
+
+ [Display(Name = "Nom d'utilisateur")]
+ [StringLength(102)]
+ [YaRegularExpression(@"[a-zA-Z0-9 ._-]+",
+ ErrorMessage = "Caratères autorisés: lettres, chiffres, espace point tiret et souligné.")]
public string UserName { get; set; }
- [Required]
- [EmailAddress]
+ [YaRequired("Ce champ est requis.")]
+ // [EmailAddress]
[Display(Name = "Email")]
public string Email { get; set; }
- [Required]
- [StringLength(100, ErrorMessage = "Le {0} doit être long d'au moins {2} caractères.", MinimumLength = 6)]
- [DataType(DataType.Password, ErrorMessage="Les mots de passe doivent contenir au moins un caractère spécial, qui ne soit ni une lettre ni un chiffre.")]
+ [YaRequired(ErrorMessage="Spécifiez un mot de passe.")]
+ // [StringLength(100, ErrorMessage = "Le {0} doit être long d'au moins {1} caractères.", MinimumLength = 6)]
+ [DataType(DataType.Password,
+ ErrorMessage = "Les mots de passe doivent contenir au moins un caractère spécial, qui ne soit ni une lettre ni un chiffre.")]
+
[Display(Name = "Mot de passe")]
public string Password { get; set; }
- [DataType(DataType.Password)]
[Display(Name = "Confirmer le mot de passe")]
[Compare("Password", ErrorMessage = "Le mot de passe et sa confirmation ne sont pas les mêmes.")]
public string ConfirmPassword { get; set; }
diff --git a/Yavsc/Views/Account/Register.cshtml b/Yavsc/Views/Account/Register.cshtml
index 4c988da2..0e45b3f6 100755
--- a/Yavsc/Views/Account/Register.cshtml
+++ b/Yavsc/Views/Account/Register.cshtml
@@ -17,14 +17,14 @@
diff --git a/Yavsc/Views/Account/Register.fr.cshtml b/Yavsc/Views/Account/Register.fr.cshtml
new file mode 100755
index 00000000..c7eb480a
--- /dev/null
+++ b/Yavsc/Views/Account/Register.fr.cshtml
@@ -0,0 +1,54 @@
+@model RegisterViewModel
+@{
+ ViewData["Title"] = @SR["Register"];
+}
+
+@section header{
+
+
+}
+
+@ViewData["Title"].
+
+
+
+@section Scripts {
+ @{ await Html.RenderPartialAsync("_ValidationScriptsPartial"); }
+}
diff --git a/Yavsc/Views/Shared/_Layout.cshtml b/Yavsc/Views/Shared/_Layout.cshtml
index e6215c29..97ed6c6d 100755
--- a/Yavsc/Views/Shared/_Layout.cshtml
+++ b/Yavsc/Views/Shared/_Layout.cshtml
@@ -100,8 +100,6 @@ h6 {
-
-
@await Html.PartialAsync("_LoginPartial")
@@ -112,8 +110,7 @@ h6 {
@((n.click_action==null)?SR["Fermer"]:SR[n.click_action])
@n.body
-
- }
+ }
}
@RenderSection("subbanner", required: false)