Validating the length of the username

This commit is contained in:
Sebastien Ros
2014-03-20 15:28:05 -07:00
parent 0ce6023378
commit 3316a8fd72

View File

@@ -358,11 +358,21 @@ namespace Orchard.Users.Controllers {
ModelState.AddModelError("username", T("You must specify a username."));
validate = false;
}
else {
if (userName.Length >= 255) {
ModelState.AddModelError("username", T("The username you provided is too long."));
validate = false;
}
}
if (String.IsNullOrEmpty(email)) {
ModelState.AddModelError("email", T("You must specify an email address."));
validate = false;
}
else if (email.Length >= 255) {
ModelState.AddModelError("email", T("The email address you provided is too long."));
validate = false;
}
else if (!Regex.IsMatch(email, UserPart.EmailPattern, RegexOptions.IgnoreCase)) {
// http://haacked.com/archive/2007/08/21/i-knew-how-to-validate-an-email-address-until-i.aspx
ModelState.AddModelError("email", T("You must specify a valid email address."));