diff --git a/src/Orchard.Web/Modules/Orchard.Comments/Controllers/CommentController.cs b/src/Orchard.Web/Modules/Orchard.Comments/Controllers/CommentController.cs index 2987f2d11..b10ed9166 100644 --- a/src/Orchard.Web/Modules/Orchard.Comments/Controllers/CommentController.cs +++ b/src/Orchard.Web/Modules/Orchard.Comments/Controllers/CommentController.cs @@ -35,14 +35,14 @@ namespace Orchard.Comments.Controllers { [HttpPost] public ActionResult Create(string returnUrl) { + if (!Services.Authorizer.Authorize(Permissions.AddComment, T("Couldn't add comment"))) + return !String.IsNullOrEmpty(returnUrl) + ? Redirect(returnUrl) + : Redirect("~/"); + var viewModel = new CommentsCreateViewModel(); try { UpdateModel(viewModel); - if (CurrentSite.As().Record.RequireLoginToAddComment) { - if (!_authorizer.Authorize(Permissions.AddComment, T("Couldn't add comment"))) { - return new HttpUnauthorizedResult(); - } - } var context = new CreateCommentContext { Author = viewModel.Name, @@ -54,13 +54,12 @@ namespace Orchard.Comments.Controllers { Comment comment = _commentService.CreateComment(context, CurrentSite.As().Record.ModerateComments); - if (!String.IsNullOrEmpty(returnUrl)) { - if (comment.Record.Status == CommentStatus.Pending) - Services.Notifier.Information(T("Your comment will appear after the site administrator approves it.")); + if (comment.Record.Status == CommentStatus.Pending) + Services.Notifier.Information(T("Your comment will appear after the site administrator approves it.")); - return Redirect(returnUrl); - } - return RedirectToAction("Index"); + return !String.IsNullOrEmpty(returnUrl) + ? Redirect(returnUrl) + : Redirect("~/"); } catch (Exception exception) { _notifier.Error(T("Creating Comment failed: " + exception.Message)); diff --git a/src/Orchard.Web/Modules/Orchard.Comments/Models/CommentSettingsRecord.cs b/src/Orchard.Web/Modules/Orchard.Comments/Models/CommentSettingsRecord.cs index 618a6179e..a75f68b22 100644 --- a/src/Orchard.Web/Modules/Orchard.Comments/Models/CommentSettingsRecord.cs +++ b/src/Orchard.Web/Modules/Orchard.Comments/Models/CommentSettingsRecord.cs @@ -2,7 +2,6 @@ using Orchard.ContentManagement.Records; namespace Orchard.Comments.Models { public class CommentSettingsRecord : ContentPartRecord { - public virtual bool RequireLoginToAddComment { get; set; } public virtual bool ModerateComments { get; set; } public virtual bool EnableSpamProtection { get; set; } public virtual string AkismetKey { get; set; } diff --git a/src/Orchard.Web/Modules/Orchard.Comments/Views/EditorTemplates/Parts/Comments.SiteSettings.ascx b/src/Orchard.Web/Modules/Orchard.Comments/Views/EditorTemplates/Parts/Comments.SiteSettings.ascx index 09e78b7c7..97243bb21 100644 --- a/src/Orchard.Web/Modules/Orchard.Comments/Views/EditorTemplates/Parts/Comments.SiteSettings.ascx +++ b/src/Orchard.Web/Modules/Orchard.Comments/Views/EditorTemplates/Parts/Comments.SiteSettings.ascx @@ -2,11 +2,6 @@ <%@ Import Namespace="Orchard.Comments.Models"%>
<%=_Encoded("Comments")%> -
- <%=Html.EditorFor(m => m.RequireLoginToAddComment) %> - - <%=Html.ValidationMessage("RequireLoginToAddComment", "*")%> -
<%=Html.EditorFor(m => m.ModerateComments) %>