mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2025-10-15 19:54:57 +08:00
Merge
--HG-- branch : 1.x
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
using System;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using Orchard.Localization;
|
||||
using System.Security.Principal;
|
||||
@@ -317,6 +318,8 @@ namespace Orchard.Users.Controllers {
|
||||
private bool ValidateRegistration(string userName, string email, string password, string confirmPassword) {
|
||||
bool validate = true;
|
||||
|
||||
Regex isValidEmail = new Regex("^[a-z0-9_\\+-]+(\\.[a-z0-9_\\+-]+)*@[a-z0-9-]+(\\.[a-z0-9-]+)*\\.([a-z]{2,4})$");
|
||||
|
||||
if (String.IsNullOrEmpty(userName)) {
|
||||
ModelState.AddModelError("username", T("You must specify a username."));
|
||||
validate = false;
|
||||
@@ -326,6 +329,11 @@ namespace Orchard.Users.Controllers {
|
||||
validate = false;
|
||||
}
|
||||
|
||||
if (!isValidEmail.IsMatch(email)) {
|
||||
ModelState.AddModelError("email", T("You must specify a valid email address."));
|
||||
validate = false;
|
||||
}
|
||||
|
||||
if (!validate)
|
||||
return false;
|
||||
|
||||
|
@@ -7,6 +7,7 @@ namespace Orchard.Users.ViewModels {
|
||||
public string UserName { get; set; }
|
||||
|
||||
[Required, DataType(DataType.EmailAddress)]
|
||||
[RegularExpression("^[a-z0-9_\\+-]+(\\.[a-z0-9_\\+-]+)*@[a-z0-9-]+(\\.[a-z0-9-]+)*\\.([a-z]{2,4})$")]
|
||||
public string Email { get; set; }
|
||||
|
||||
[Required, DataType(DataType.Password)]
|
||||
|
@@ -11,6 +11,7 @@ namespace Orchard.Users.ViewModels {
|
||||
}
|
||||
|
||||
[Required]
|
||||
[RegularExpression("^[a-z0-9_\\+-]+(\\.[a-z0-9_\\+-]+)*@[a-z0-9-]+(\\.[a-z0-9-]+)*\\.([a-z]{2,4})$")]
|
||||
public string Email {
|
||||
get { return User.As<UserPart>().Record.Email; }
|
||||
set { User.As<UserPart>().Record.Email = value; }
|
||||
|
Reference in New Issue
Block a user