/// <summary> /// Method to validate email /// </summary> /// <param name="c"></param> public void ValidateEmail(Controller c) { //email if (!string.IsNullOrEmpty(Email)) { //Regex regEx = new Regex("^[_A-Za-z0-9-]+(\\.[_A-Za-z0-9-]+)*@[A-Za-z0-9]+(\\.[A-Za-z0-9]+)*(\\.[A-Za-z]{2,})$"); //if (!regEx.IsMatch(Email)) RegexUtilities util = new RegexUtilities(); if (!util.IsValidEmail(Email)) c.ModelState.AddModelError("", Resources.Common.EmailFormatNotValid); } else { c.ModelState.AddModelError("", string.Format(Resources.Common.SpecificMadatoryField, Resources.Common.Email)); } }
/// <summary> /// Method to validate New Password /// </summary> /// <param name="c"></param> private void ValidateNewPassword(Controller c) { //new password if (!string.IsNullOrEmpty(NewPassword)) { if (NewPassword.Length < Cotecna.Voc.Web.Properties.Settings.Default.MinLenghtPassword || NewPassword.Length > Cotecna.Voc.Web.Properties.Settings.Default.MaxLenghtPassword) { c.ModelState.AddModelError("", Resources.Common.ShortPasswordValidation); } else { RegexUtilities util = new RegexUtilities(); if (!util.IsValidCotecnaPasswordFormat(NewPassword)) c.ModelState.AddModelError("", Resources.Common.FormatPasswordValidation); } } else { if (ScreenOpenMode == (int)OpenMode.New) { c.ModelState.AddModelError("", string.Format(Resources.Common.SpecificMadatoryField, Resources.Common.Password)); } } }
private void ValidateChangePassword(ChangePasswordModel model) { RegexUtilities util = new RegexUtilities(); //the system validates old password if (string.IsNullOrEmpty(model.OldPassword)) ModelState.AddModelError("OldPassRequired", Resources.Common.OldPassRequired); if (model.OldPassword.Length < model.MinLenghtPassword) ModelState.AddModelError("", Resources.Common.MinLegthPassword); //The system validates new password if (string.IsNullOrEmpty(model.NewPassword)) ModelState.AddModelError("NewPassRequired", Resources.Common.NewPassRequired); if (model.NewPassword.Length < model.MinLenghtPassword) ModelState.AddModelError("", Resources.Common.MinLegthPassword); //the system validates new password if (string.IsNullOrEmpty(model.ReNewPassword)) ModelState.AddModelError("ReNewPassWordRequired", Resources.Common.ReNewPassWordRequired); if (model.ReNewPassword.Length < model.MinLenghtPassword) ModelState.AddModelError("", Resources.Common.MinLegthPassword); //the system validates if the new password and the ReNewPassword are equals if (model.NewPassword != model.ReNewPassword) ModelState.AddModelError("", Resources.Common.NotIqualPasswordValidation); //validate the temporary password if (!CompareTemporalPassword(model.UserName, model.OldPassword)) ModelState.AddModelError("", "The temporary password is not correct"); if (!util.IsValidCotecnaPasswordFormat(model.NewPassword)) ModelState.AddModelError("", Resources.Common.FormatPasswordValidation); if (!util.IsValidCotecnaPasswordFormat(model.ReNewPassword)) ModelState.AddModelError("", Resources.Common.FormatPasswordValidation); }