Skip to content

Instantly share code, notes, and snippets.

@bleroy
Created April 1, 2015 22:12
Show Gist options
  • Save bleroy/d8821149bc129e0894d4 to your computer and use it in GitHub Desktop.
Save bleroy/d8821149bc129e0894d4 to your computer and use it in GitHub Desktop.
CodePlex Issue #16341 Plain Text Attachments
diff --git a/src/Orchard.Web/Modules/Orchard.Blogs/Controllers/BlogPostAdminController.cs b/src/Orchard.Web/Modules/Orchard.Blogs/Controllers/BlogPostAdminController.cs
--- a/src/Orchard.Web/Modules/Orchard.Blogs/Controllers/BlogPostAdminController.cs
+++ b/src/Orchard.Web/Modules/Orchard.Blogs/Controllers/BlogPostAdminController.cs
@@ -13,6 +13,7 @@
using Orchard.UI.Admin;
using Orchard.UI.Notify;
using Orchard.Extensions;
+using Orchard.Utility.Extensions;
namespace Orchard.Blogs.Controllers {
[ValidateInput(false), Admin]
diff --git a/src/Orchard.Web/Modules/Orchard.Users/Controllers/AccountController.cs b/src/Orchard.Web/Modules/Orchard.Users/Controllers/AccountController.cs
--- a/src/Orchard.Web/Modules/Orchard.Users/Controllers/AccountController.cs
+++ b/src/Orchard.Web/Modules/Orchard.Users/Controllers/AccountController.cs
@@ -111,10 +111,14 @@
}
[Authorize]
- public ActionResult ChangePassword() {
- ViewData["PasswordLength"] = MinPasswordLength;
+ public ActionResult ChangePassword() {
- return View(new BaseViewModel());
+ ChangePasswordViewModel model = new ChangePasswordViewModel {
+ MinPasswordLength =
+ _membershipService.GetSettings().
+ MinRequiredPasswordLength
+ };
+ return View(model);
}
[Authorize]
diff --git a/src/Orchard.Web/Modules/Orchard.Users/Orchard.Users.csproj b/src/Orchard.Web/Modules/Orchard.Users/Orchard.Users.csproj
--- a/src/Orchard.Web/Modules/Orchard.Users/Orchard.Users.csproj
+++ b/src/Orchard.Web/Modules/Orchard.Users/Orchard.Users.csproj
@@ -73,6 +73,7 @@
<Compile Include="Services\MembershipService.cs" />
<Compile Include="AdminMenu.cs" />
<Compile Include="Services\UserService.cs" />
+ <Compile Include="ViewModels\ChangePasswordViewModel.cs" />
<Compile Include="ViewModels\LogOnViewModel.cs" />
<Compile Include="ViewModels\UserCreateViewModel.cs" />
<Compile Include="ViewModels\UserEditViewModel.cs" />
diff --git a/src/Orchard.Web/Modules/Orchard.Users/ViewModels/ChangePasswordViewModel.cs b/src/Orchard.Web/Modules/Orchard.Users/ViewModels/ChangePasswordViewModel.cs
new file mode 100644
--- /dev/null
+++ b/src/Orchard.Web/Modules/Orchard.Users/ViewModels/ChangePasswordViewModel.cs
@@ -0,0 +1,9 @@
+using Orchard.Mvc.ViewModels;
+
+namespace Orchard.Users.ViewModels
+{
+ public class ChangePasswordViewModel : BaseViewModel
+ {
+ public int MinPasswordLength { get; set; }
+ }
+}
diff --git a/src/Orchard.Web/Modules/Orchard.Users/Views/Account/ChangePassword.ascx b/src/Orchard.Web/Modules/Orchard.Users/Views/Account/ChangePassword.ascx
--- a/src/Orchard.Web/Modules/Orchard.Users/Views/Account/ChangePassword.ascx
+++ b/src/Orchard.Web/Modules/Orchard.Users/Views/Account/ChangePassword.ascx
@@ -1,8 +1,9 @@
-<%@ Control Language="C#" Inherits="Orchard.Mvc.ViewUserControl<object>" %>
+<%@ Control Language="C#" Inherits="Orchard.Mvc.ViewUserControl<ChangePasswordViewModel>" %>
+<%@ Import Namespace="Orchard.Users.ViewModels"%>
<%@ Import Namespace="Orchard.Mvc.ViewModels"%>
<h1><%=Html.TitleForPage(T("Change Password").ToString()) %></h1>
<p><%=_Encoded("Use the form below to change your password.")%></p>
-<p><%=_Encoded("New passwords are required to be a minimum of {0} characters in length.", ViewData["PasswordLength"] as string) %></p>
+<p><%=_Encoded("New passwords are required to be a minimum of {0} characters in length.", Model.MinPasswordLength) %></p>
<%=Html.ValidationSummary(T("Password change was unsuccessful. Please correct the errors and try again.").ToString())%>
<% using (Html.BeginFormAntiForgeryPost("ChangePassword", FormMethod.Post)) { %>
<fieldset>
diff --git a/src/Orchard.Web/Modules/Orchard.Users/Views/Account/Profile.ascx b/src/Orchard.Web/Modules/Orchard.Users/Views/Account/Profile.ascx
--- a/src/Orchard.Web/Modules/Orchard.Users/Views/Account/Profile.ascx
+++ b/src/Orchard.Web/Modules/Orchard.Users/Views/Account/Profile.ascx
@@ -1,4 +1,6 @@
<%@ Control Language="C#" Inherits="Orchard.Mvc.ViewUserControl<BaseViewModel>" %>
<%@ Import Namespace="Orchard.Mvc.ViewModels"%>
-<% Html.RenderPartial("ChangePassword"); %>
+<%--<% Html.RenderPartial("ChangePassword"); %>--%>
+<% Model.Zones.AddRenderAction("body", "ChangePassword"); %>
+
diff --git a/src/Orchard.Web/Core/Themes/Views/User.ascx b/src/Orchard.Web/Core/Themes/Views/User.ascx
--- a/src/Orchard.Web/Core/Themes/Views/User.ascx
+++ b/src/Orchard.Web/Core/Themes/Views/User.ascx
@@ -5,6 +5,7 @@
<%=T("Welcome, <strong>{0}</strong>!", Html.Encode(Page.User.Identity.Name)) %>
<%=Html.ActionLink(T("Log Off").ToString(), "LogOff", new { Controller = "Account", Area = "Orchard.Users", ReturnUrl = Context.Request.RawUrl })%>
&nbsp;&#124;&nbsp;<%= Html.ActionLink("Admin", "Index", new {Area = "Dashboard", Controller = "Admin"})%>
+ &nbsp;&#124;&nbsp;<%= Html.ActionLink("Profile", "Profile", new { Controller = "Account", Area = "Orchard.Users", ReturnUrl = Context.Request.RawUrl }) %>
<% } else { %>
<%=Html.ActionLink(T("Log On").ToString(), "LogOn", new { Controller = "Account", Area = "Orchard.Users", ReturnUrl = Context.Request.RawUrl }) %>
<% } %>
diff --git a/src/Orchard.Web/Modules/Orchard.Users/Controllers/AccountController.cs b/src/Orchard.Web/Modules/Orchard.Users/Controllers/AccountController.cs
--- a/src/Orchard.Web/Modules/Orchard.Users/Controllers/AccountController.cs
+++ b/src/Orchard.Web/Modules/Orchard.Users/Controllers/AccountController.cs
@@ -84,6 +84,10 @@
return View(new BaseViewModel());
}
+ public ActionResult Profile() {
+ return View(new BaseViewModel());
+ }
+
[HttpPost]
public ActionResult Register(string userName, string email, string password, string confirmPassword) {
ViewData["PasswordLength"] = MinPasswordLength;
@@ -121,7 +125,7 @@
ViewData["PasswordLength"] = MinPasswordLength;
if (!ValidateChangePassword(currentPassword, newPassword, confirmPassword)) {
- return View();
+ return ChangePassword();
}
try {
diff --git a/src/Orchard.Web/Modules/Orchard.Users/Orchard.Users.csproj b/src/Orchard.Web/Modules/Orchard.Users/Orchard.Users.csproj
--- a/src/Orchard.Web/Modules/Orchard.Users/Orchard.Users.csproj
+++ b/src/Orchard.Web/Modules/Orchard.Users/Orchard.Users.csproj
@@ -84,6 +84,7 @@
<Content Include="Views\Account\ChangePasswordSuccess.ascx" />
<Content Include="Views\Account\AccessDenied.ascx" />
<Content Include="Views\Account\LogOn.ascx" />
+ <Content Include="Views\Account\Profile.ascx" />
<Content Include="Views\Account\Register.ascx" />
<Content Include="Views\Admin\Edit.aspx" />
<Content Include="Views\Admin\Create.aspx" />
diff --git a/src/Orchard.Web/Modules/Orchard.Users/Views/Account/ChangePassword.ascx b/src/Orchard.Web/Modules/Orchard.Users/Views/Account/ChangePassword.ascx
--- a/src/Orchard.Web/Modules/Orchard.Users/Views/Account/ChangePassword.ascx
+++ b/src/Orchard.Web/Modules/Orchard.Users/Views/Account/ChangePassword.ascx
@@ -1,9 +1,10 @@
<%@ Control Language="C#" Inherits="Orchard.Mvc.ViewUserControl<object>" %>
+<%@ Import Namespace="Orchard.Mvc.ViewModels"%>
<h1><%=Html.TitleForPage(T("Change Password").ToString()) %></h1>
<p><%=_Encoded("Use the form below to change your password.")%></p>
<p><%=_Encoded("New passwords are required to be a minimum of {0} characters in length.", ViewData["PasswordLength"] as string) %></p>
<%=Html.ValidationSummary(T("Password change was unsuccessful. Please correct the errors and try again.").ToString())%>
-<% using (Html.BeginFormAntiForgeryPost()) { %>
+<% using (Html.BeginFormAntiForgeryPost("ChangePassword", FormMethod.Post)) { %>
<fieldset>
<legend><%=_Encoded("Account Information")%></legend>
<div>
diff --git a/src/Orchard.Web/Modules/Orchard.Users/Views/Account/Profile.ascx b/src/Orchard.Web/Modules/Orchard.Users/Views/Account/Profile.ascx
new file mode 100644
--- /dev/null
+++ b/src/Orchard.Web/Modules/Orchard.Users/Views/Account/Profile.ascx
@@ -0,0 +1,4 @@
+<%@ Control Language="C#" Inherits="Orchard.Mvc.ViewUserControl<BaseViewModel>" %>
+<%@ Import Namespace="Orchard.Mvc.ViewModels"%>
+<% Html.RenderPartial("ChangePassword"); %>
+
diff --git a/src/Orchard.Web/Themes/Classic/Styles/site.css b/src/Orchard.Web/Themes/Classic/Styles/site.css
--- a/src/Orchard.Web/Themes/Classic/Styles/site.css
+++ b/src/Orchard.Web/Themes/Classic/Styles/site.css
@@ -41,7 +41,7 @@
h1.sitename {border-bottom:none;}
-p {line-height:24px; margin:12px 0 32px 0;}
+p {line-height:24px; margin:12px 0 12px 0;}
p.small {line-height:24px; font-size:85%;}
a {color:#004386; text-decoration:none;} /* unvisited link */
@@ -58,7 +58,7 @@
/* Forms
----------------------------------------------------------*/
-input[type="text"], #CommentText, #password, #confirmPassword {
+input[type="text"], #CommentText, #password, #confirmPassword, #currentPassword, #newPassword {
border:1px solid #cacec6;
display: block;
padding:2px;
diff --git a/src/Orchard.Web/Themes/ClassicDark/Styles/site.css b/src/Orchard.Web/Themes/ClassicDark/Styles/site.css
--- a/src/Orchard.Web/Themes/ClassicDark/Styles/site.css
+++ b/src/Orchard.Web/Themes/ClassicDark/Styles/site.css
@@ -40,7 +40,7 @@
h1.sitename {border-bottom:none;}
-p {line-height:24px; margin:12px 0 32px 0;}
+p {line-height:24px; margin:12px 0 12px 0;}
p.small {line-height:24px; font-size:85%;}
a {color:#ccdcce; text-decoration:underline;} /* unvisited link */
@@ -61,7 +61,7 @@
/* Forms
----------------------------------------------------------*/
-input[type="text"], #CommentText, #password, #confirmPassword {
+input[type="text"], #CommentText, #password, #confirmPassword, #currentPassword, #newPassword {
border:1px solid #cacec6;
background:#DEDEDE;
display: block;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment