Define constants for maximum username/email length

This commit is contained in:
Marek Dzikiewicz
2014-12-18 23:29:50 +01:00
parent 1729e73a73
commit c9ebd1db67
2 changed files with 5 additions and 2 deletions

View File

@@ -362,7 +362,7 @@ namespace Orchard.Users.Controllers {
validate = false;
}
else {
if (userName.Length >= 255) {
if (userName.Length >= UserPart.MaxUserNameLength) {
ModelState.AddModelError("username", T("The username you provided is too long."));
validate = false;
}
@@ -372,7 +372,7 @@ namespace Orchard.Users.Controllers {
ModelState.AddModelError("email", T("You must specify an email address."));
validate = false;
}
else if (email.Length >= 255) {
else if (email.Length >= UserPart.MaxEmailLength) {
ModelState.AddModelError("email", T("The email address you provided is too long."));
validate = false;
}

View File

@@ -7,6 +7,9 @@ namespace Orchard.Users.Models {
public const string EmailPattern =
@"^(?![\.@])(""([^""\r\\]|\\[""\r\\])*""|([-a-z0-9!#$%&'*+/=?^_`{|}~]|(?<!\.)\.)*)(?<!\.)"
+ @"@([a-z0-9][\w-]*\.)+[a-z]{2,}$";
public const int MaxUserNameLength = 255;
public const int MaxEmailLength = 255;
public string UserName {
get { return Retrieve(x => x.UserName); }