mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2025-10-21 11:17:28 +08:00
Validating the length of the username
This commit is contained in:
@@ -358,11 +358,21 @@ namespace Orchard.Users.Controllers {
|
|||||||
ModelState.AddModelError("username", T("You must specify a username."));
|
ModelState.AddModelError("username", T("You must specify a username."));
|
||||||
validate = false;
|
validate = false;
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
if (userName.Length >= 255) {
|
||||||
|
ModelState.AddModelError("username", T("The username you provided is too long."));
|
||||||
|
validate = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (String.IsNullOrEmpty(email)) {
|
if (String.IsNullOrEmpty(email)) {
|
||||||
ModelState.AddModelError("email", T("You must specify an email address."));
|
ModelState.AddModelError("email", T("You must specify an email address."));
|
||||||
validate = false;
|
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)) {
|
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
|
// 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."));
|
ModelState.AddModelError("email", T("You must specify a valid email address."));
|
||||||
|
Reference in New Issue
Block a user