mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2025-09-19 10:07:55 +08:00
- Comments: allow anonymous comments when the RequireLoginToAddComment setting is true.
--HG-- extra : convert_revision : svn%3A5ff7c347-ad56-4c35-b696-ccb81de16e03/trunk%4041927
This commit is contained in:
@@ -6,6 +6,7 @@ using System.Web.Mvc;
|
||||
using Orchard.Comments.Models;
|
||||
using Orchard.Localization;
|
||||
using Orchard.Logging;
|
||||
using Orchard.Models;
|
||||
using Orchard.Settings;
|
||||
using Orchard.UI.Notify;
|
||||
using Orchard.Security;
|
||||
@@ -113,15 +114,17 @@ namespace Orchard.Comments.Controllers {
|
||||
var viewModel = new CommentsCreateViewModel();
|
||||
try {
|
||||
UpdateModel(viewModel, input.ToValueProvider());
|
||||
if (!_authorizer.Authorize(Permissions.AddComment, T("Couldn't add comment")))
|
||||
return new HttpUnauthorizedResult();
|
||||
if (CurrentSite.As<CommentSettings>().Record.RequireLoginToAddComment) {
|
||||
if (!_authorizer.Authorize(Permissions.AddComment, T("Couldn't add comment")))
|
||||
return new HttpUnauthorizedResult();
|
||||
}
|
||||
Comment comment = new Comment {
|
||||
Author = viewModel.Name,
|
||||
CommentDate = DateTime.Now,
|
||||
CommentText = viewModel.CommentText,
|
||||
Email = viewModel.Email,
|
||||
SiteName = viewModel.SiteName,
|
||||
UserName = CurrentUser.UserName ?? "Anonymous",
|
||||
UserName = CurrentUser == null ? "Anonymous" : CurrentUser.UserName,
|
||||
CommentedOn = viewModel.CommentedOn
|
||||
};
|
||||
_commentService.CreateComment(comment);
|
||||
|
Reference in New Issue
Block a user