--HG--
branch : 1.x
This commit is contained in:
Suha Can
2011-01-18 10:37:49 -08:00
4 changed files with 45 additions and 0 deletions

View File

@@ -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;

View File

@@ -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)]

View File

@@ -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; }