mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2025-10-15 19:54:57 +08:00
Fixing email validation
--HG-- branch : 1.x extra : rebase_source : 2fad794d173a2ae986ded39f13d2b4e9ccc13926
This commit is contained in:
@@ -33,6 +33,23 @@ namespace Orchard.Comments.Controllers {
|
||||
|
||||
var editorShape = Services.ContentManager.UpdateEditor(comment, this);
|
||||
|
||||
|
||||
if (!ModelState.IsValidField("Author")) {
|
||||
Services.Notifier.Error(T("Name is mandatory and must have less than 255 chars"));
|
||||
}
|
||||
|
||||
if (!ModelState.IsValidField("Email")) {
|
||||
Services.Notifier.Error(T("Email is invalid or is longer than 255 chars"));
|
||||
}
|
||||
|
||||
if (!ModelState.IsValidField("Site")) {
|
||||
Services.Notifier.Error(T("Site url is invalid or is longer than 255 chars"));
|
||||
}
|
||||
|
||||
if (!ModelState.IsValidField("CommentText")) {
|
||||
Services.Notifier.Error(T("Comment is mandatory"));
|
||||
}
|
||||
|
||||
if (ModelState.IsValid) {
|
||||
Services.ContentManager.Create(comment);
|
||||
|
||||
@@ -109,10 +126,6 @@ namespace Orchard.Comments.Controllers {
|
||||
else {
|
||||
Services.TransactionManager.Cancel();
|
||||
|
||||
foreach (var error in ModelState.Values.SelectMany(m => m.Errors).Select(e => e.ErrorMessage)) {
|
||||
_notifier.Error(T(error));
|
||||
}
|
||||
|
||||
TempData["Comments.InvalidCommentEditorShape"] = editorShape;
|
||||
var commentPart = comment.As<CommentPart>();
|
||||
if(commentPart.RepliedOn.HasValue) {
|
||||
|
@@ -121,8 +121,6 @@ namespace Orchard.Comments.Drivers {
|
||||
|
||||
if (currentUser != null) part.Author = currentUser.UserName;
|
||||
|
||||
if (String.IsNullOrEmpty(part.Author)) updater.AddModelError("NameMissing", T("You didn't specify your name."));
|
||||
|
||||
var moderateComments = workContext.CurrentSite.As<CommentSettingsPart>().Record.ModerateComments;
|
||||
part.Status = moderateComments ? CommentStatus.Pending : CommentStatus.Approved;
|
||||
|
||||
|
@@ -12,6 +12,7 @@ namespace Orchard.Comments.Models {
|
||||
public LazyField<ContentItem> CommentedOnContentItemField { get { return _commentedOnContentItem; } }
|
||||
public LazyField<ContentItemMetadata> CommentedOnContentItemMetadataField { get { return _commentedOnContentItemMetadata; } }
|
||||
|
||||
[StringLength(255)]
|
||||
public string Author {
|
||||
get { return Record.Author; }
|
||||
set { Record.Author = value; }
|
||||
@@ -19,7 +20,7 @@ namespace Orchard.Comments.Models {
|
||||
|
||||
[StringLength(245)]
|
||||
[DisplayName("Site")]
|
||||
[RegularExpression(@"^(http(s)?://)?([a-zA-Z0-9]([a-zA-Z0-9-]*[a-zA-Z0-9])?\.)+[a-zA-Z]{2,}[\S]+$", ErrorMessage = "Invalid url")]
|
||||
[RegularExpression(@"^(http(s)?://)?([a-zA-Z0-9]([a-zA-Z0-9-]*[a-zA-Z0-9])?\.)+[a-zA-Z]{2,}[\S]+$")]
|
||||
public string SiteName {
|
||||
get { return Record.SiteName; }
|
||||
set { Record.SiteName = value; }
|
||||
@@ -30,8 +31,7 @@ namespace Orchard.Comments.Models {
|
||||
set { Record.UserName = value; }
|
||||
}
|
||||
|
||||
[RegularExpression(@"^[^@\s]+@[^@\s]+$", ErrorMessage = "Invalid Email")]
|
||||
[StringLength(255)]
|
||||
[RegularExpression(@"^(?![\.@])(""([^""\r\\]|\\[""\r\\])*""|([-a-z0-9!#$%&'*+/=?^_`{|}~]|(?<!\.)\.)*)(?<!\.)@[a-z0-9][\w\.-]*[a-z0-9]\.[a-z][a-z\.]*[a-z]$")]
|
||||
public string Email {
|
||||
get { return Record.Email; }
|
||||
set { Record.Email = value; }
|
||||
|
Reference in New Issue
Block a user