mercredi 23 septembre 2015

Membership issue with MySQL Provider and ASP.NET MVC 5, minRequiredNonalphanumericCharacters not taken into account

I'm currently working on a web project, but after some pre-alpha testing, I've been told that requiring non alpha numeric characters in the password at registration was too much. They want to be able to use only letters and numbers (with caps eventually).

So I've headed to my web.config to edit the provider's tag, however it doesn't change anything when the value's at 0. My provider is defined as default provider, and there shouldn't be any override of the form control method, so I'm somehow at a loss here.

Here's the provider line from my web.config:

<membership defaultProvider="MySQLMembershipProvider">
  <providers>
    <remove name="MySQLMembershipProvider" />
    <add name="MySQLMembershipProvider" type="MySql.Web.Security.MySQLMembershipProvider, MySql.Web, Version=6.9.7.0, Culture=neutral, PublicKeyToken=x" connectionStringName="LocalMySqlServer" enablePasswordRetrieval="false" enablePasswordReset="true" requiresQuestionAndAnswer="true" applicationName="/" requiresUniqueEmail="false" passwordFormat="Clear" maxInvalidPasswordAttempts="5" minRequiredPasswordLength="6" minRequiredNonalphanumericCharacters="0" passwordAttemptWindow="10" passwordStrengthRegularExpression="" />
  </providers>
</membership>

Here's my model method concerning the registration form:

public class RegisterViewModel
{
    [Required]
    [EmailAddress]
    [Display(Name = "Courrier électronique")]
    public string Email { get; set; }

    [Required]
    [StringLength(100, ErrorMessage = "La chaîne {0} doit comporter au moins {2} caractères.", MinimumLength = 6)]
    [DataType(DataType.Password)]
    [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 le mot de passe de confirmation ne correspondent pas.")]
    public string ConfirmPassword { get; set; }

    [MustBeTrue(ErrorMessage = "Vous devez accepter les conditions générales d'utilisation.")]
    [Display(Name = "Accepter les conditions générales d'utilisation ")]
    public bool AccepteConditions { get; set; }
}

I've tried to change the value of minRequiredNonalphanumericCharacters to 2, but of course, the error message is generic and doesn't change. So I can't really say if the provider is used at all. So basically, wether I put the value to 0, 1 or 2, the error message doesn't go away if I try to type an alphanumeric password, but lets me through without issue as long as I put at least 1 character.




Aucun commentaire:

Enregistrer un commentaire