mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2025-10-15 19:54:57 +08:00
Merge pull request #5156 from MpDzik/pr/users-consts2
Define constants for maximum username/email length
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
@@ -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); }
|
||||
|
Reference in New Issue
Block a user