mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2026-02-09 09:16:41 +08:00
#20689 Reverting previous changes and jsut forcing validation if author is null when user is not signed in
This commit is contained in:
@@ -106,7 +106,11 @@ namespace Orchard.Comments.Drivers {
|
||||
var currentUser = workContext.CurrentUser;
|
||||
part.UserName = (currentUser != null ? currentUser.UserName : null);
|
||||
|
||||
if (currentUser != null) part.Author = currentUser.UserName;
|
||||
if (currentUser != null)
|
||||
part.Author = currentUser.UserName;
|
||||
else if (string.IsNullOrWhiteSpace(part.Author)) {
|
||||
updater.AddModelError("Comments.Author", T("Name is mandatory"));
|
||||
}
|
||||
|
||||
var moderateComments = workContext.CurrentSite.As<CommentSettingsPart>().ModerateComments;
|
||||
part.Status = moderateComments ? CommentStatus.Pending : CommentStatus.Approved;
|
||||
|
||||
@@ -12,7 +12,7 @@ namespace Orchard.Comments.Models {
|
||||
public LazyField<ContentItem> CommentedOnContentItemField { get { return _commentedOnContentItem; } }
|
||||
public LazyField<ContentItemMetadata> CommentedOnContentItemMetadataField { get { return _commentedOnContentItemMetadata; } }
|
||||
|
||||
[Required, StringLength(255)]
|
||||
[StringLength(255)]
|
||||
public string Author {
|
||||
get { return Record.Author; }
|
||||
set { Record.Author = value; }
|
||||
@@ -31,7 +31,7 @@ namespace Orchard.Comments.Models {
|
||||
set { Record.UserName = value; }
|
||||
}
|
||||
|
||||
[Required, RegularExpression(@"^(?![\.@])(""([^""\r\\]|\\[""\r\\])*""|([-a-z0-9!#$%&'*+/=?^_`{|}~]|(?<!\.)\.)*)(?<!\.)@[a-z0-9][\w\.-]*[a-z0-9]\.[a-z][a-z\.]*[a-z]$")]
|
||||
[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; }
|
||||
|
||||
@@ -7,11 +7,11 @@
|
||||
<ol>
|
||||
<li>
|
||||
@Html.LabelFor(m => m.Author, T("Name"))
|
||||
@Html.TextBoxFor(m => m.Author, new { required = "required" })
|
||||
@Html.TextBoxFor(m => m.Author)
|
||||
</li>
|
||||
<li>
|
||||
@Html.LabelFor(m => m.Email, T("Email"))
|
||||
@Html.TextBoxFor(m => m.Email, new { required = "required" })
|
||||
@Html.TextBoxFor(m => m.Email)
|
||||
</li>
|
||||
<li>
|
||||
@Html.LabelFor(m => m.SiteName, T("Url"))
|
||||
@@ -21,7 +21,7 @@
|
||||
</fieldset>
|
||||
}
|
||||
else {
|
||||
@Html.Hidden("Author", WorkContext.CurrentUser.UserName ?? "")
|
||||
@Html.Hidden("Name", WorkContext.CurrentUser.UserName ?? "")
|
||||
@Html.Hidden("Email", WorkContext.CurrentUser.Email ?? "")
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user