mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2025-09-22 20:13:50 +08:00
Cleaning up the "add comment" UI
- If the user is not authenticated and doesn't have permission to add a comment a message is given for them to "log on" - "log on" link to add a comment hashed appropriately so the browser drops down to the comment form on return after logging on - Updated the default User template to give the log off link a return URL and updated the AccountController to do the same redirect to the given location, if given, on action completion so the user is returned to the same location they left. The "log off" link in an admin theme should never include a return URL because the resulting experience would be bad (they'd be sent back to the log on page with a not authorized message) --HG-- branch : dev
This commit is contained in:
@@ -3,7 +3,7 @@
|
|||||||
<div id="logindisplay">
|
<div id="logindisplay">
|
||||||
<% if (Request.IsAuthenticated) { %>
|
<% if (Request.IsAuthenticated) { %>
|
||||||
<%=T("Welcome, <strong>{0}</strong>!", Html.Encode(Page.User.Identity.Name)) %>
|
<%=T("Welcome, <strong>{0}</strong>!", Html.Encode(Page.User.Identity.Name)) %>
|
||||||
<%=Html.ActionLink(T("Log Off").ToString(), "LogOff", new { Controller = "Account", Area = "Orchard.Users" })%>
|
<%=Html.ActionLink(T("Log Off").ToString(), "LogOff", new { Controller = "Account", Area = "Orchard.Users", ReturnUrl = Context.Request.RawUrl })%>
|
||||||
| <%= Html.ActionLink("Admin", "Index", new {Area = "Dashboard", Controller = "Admin"})%>
|
| <%= Html.ActionLink("Admin", "Index", new {Area = "Dashboard", Controller = "Admin"})%>
|
||||||
<% } else { %>
|
<% } else { %>
|
||||||
<%=Html.ActionLink(T("Log On").ToString(), "LogOn", new { Controller = "Account", Area = "Orchard.Users", ReturnUrl = Context.Request.RawUrl }) %>
|
<%=Html.ActionLink(T("Log On").ToString(), "LogOn", new { Controller = "Account", Area = "Orchard.Users", ReturnUrl = Context.Request.RawUrl }) %>
|
||||||
|
@@ -1,17 +1,26 @@
|
|||||||
<%@ Control Language="C#" Inherits="Orchard.Mvc.ViewUserControl<HasComments>" %>
|
<%@ Control Language="C#" Inherits="Orchard.Mvc.ViewUserControl<HasComments>" %>
|
||||||
|
<%@ Import Namespace="Orchard.Comments"%>
|
||||||
<%@ Import Namespace="Orchard.Security" %>
|
<%@ Import Namespace="Orchard.Security" %>
|
||||||
<%@ Import Namespace="Orchard.Comments.Models" %><%
|
<%@ Import Namespace="Orchard.Comments.Models" %>
|
||||||
|
<%-- todo: clean up this template - waaay too much going on in here :/ --%><%
|
||||||
if (Model.Comments.Count > 0) { %>
|
if (Model.Comments.Count > 0) { %>
|
||||||
<h2 id="comments"><%=_Encoded("{0} Comment{1}", Model.Comments.Count, Model.Comments.Count == 1 ? "" : "s")%></h2><% Html.RenderPartial("ListOfComments", Model.Comments); }
|
<h2 id="comments"><%=_Encoded("{0} Comment{1}", Model.Comments.Count, Model.Comments.Count == 1 ? "" : "s")%></h2>
|
||||||
|
<% Html.RenderPartial("ListOfComments", Model.Comments);
|
||||||
|
}
|
||||||
|
|
||||||
if (Model.CommentsActive == false) {
|
if (Model.CommentsActive == false) {
|
||||||
if (Model.Comments.Count > 0) { %>
|
if (Model.Comments.Count > 0) { %>
|
||||||
<p><%=_Encoded("Comments have been disabled for this content.") %></p><%
|
<p><%=_Encoded("Comments have been disabled for this content.") %></p><%
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else if(!Request.IsAuthenticated && !AuthorizedFor(Permissions.AddComment)) { %>
|
||||||
|
<h2 id="addacomment"><%=_Encoded("Add a Comment") %></h2>
|
||||||
|
<p class="info message"><%=T("You must {0} to comment.", Html.ActionLink(T("log on").ToString(), "LogOn", new { Controller = "Account", Area = "Orchard.Users", ReturnUrl = string.Format("{0}#addacomment", Context.Request.RawUrl) }))%></p><%
|
||||||
|
}
|
||||||
else { %>
|
else { %>
|
||||||
<% using (Html.BeginForm("Create", "Comment", new { area = "Orchard.Comments" }, FormMethod.Post, new { @class = "comment" })) { %>
|
<% using (Html.BeginForm("Create", "Comment", new { area = "Orchard.Comments" }, FormMethod.Post, new { @class = "comment" })) { %>
|
||||||
<%=Html.ValidationSummary() %>
|
<%=Html.ValidationSummary() %>
|
||||||
<h2><%=_Encoded("Add a Comment") %></h2><%
|
<h2 id="addacomment"><%=_Encoded("Add a Comment") %></h2><%
|
||||||
if (!Request.IsAuthenticated) { %>
|
if (!Request.IsAuthenticated) { %>
|
||||||
<fieldset class="who">
|
<fieldset class="who">
|
||||||
<div>
|
<div>
|
||||||
|
@@ -53,18 +53,17 @@ namespace Orchard.Users.Controllers {
|
|||||||
|
|
||||||
_authenticationService.SignIn(user, rememberMe);
|
_authenticationService.SignIn(user, rememberMe);
|
||||||
|
|
||||||
if (!String.IsNullOrEmpty(returnUrl)) {
|
return !String.IsNullOrEmpty(returnUrl)
|
||||||
return Redirect(returnUrl);
|
? Redirect(returnUrl)
|
||||||
}
|
: Redirect("~/");
|
||||||
else {
|
|
||||||
return Redirect("~/");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public ActionResult LogOff() {
|
public ActionResult LogOff(string returnUrl) {
|
||||||
_authenticationService.SignOut();
|
_authenticationService.SignOut();
|
||||||
|
|
||||||
return Redirect("~/");
|
return !String.IsNullOrEmpty(returnUrl)
|
||||||
|
? Redirect(returnUrl)
|
||||||
|
: Redirect("~/");
|
||||||
}
|
}
|
||||||
|
|
||||||
int MinPasswordLength {
|
int MinPasswordLength {
|
||||||
|
Reference in New Issue
Block a user