From 1bfdd83ba73c6af00220f0d0b286af45a3f68c79 Mon Sep 17 00:00:00 2001 From: Shannon Date: Tue, 28 Jan 2014 19:41:21 +1100 Subject: [PATCH] Cleans up more of the membership controllers and snippets to be using the membership helper and fixes up a few issues --- .../Templates/EditProfile.cshtml | 18 +-- .../PartialViews/Templates/EditProfile.cshtml | 20 ++-- .../config/umbracoSettings.config | 2 +- .../Controllers/UmbLoginController.cs | 12 +- .../Controllers/UmbLoginStatusController.cs | 2 +- .../Controllers/UmbProfileController.cs | 2 +- src/Umbraco.Web/Models/ProfileModel.cs | 56 ++++------ src/Umbraco.Web/Models/RegisterModel.cs | 1 + src/Umbraco.Web/Security/MembershipHelper.cs | 103 ++++++++++++++++-- 9 files changed, 140 insertions(+), 76 deletions(-) diff --git a/src/Umbraco.Web.UI/Umbraco/PartialViewMacros/Templates/EditProfile.cshtml b/src/Umbraco.Web.UI/Umbraco/PartialViewMacros/Templates/EditProfile.cshtml index 43ccd32ef6..1994917f2f 100644 --- a/src/Umbraco.Web.UI/Umbraco/PartialViewMacros/Templates/EditProfile.cshtml +++ b/src/Umbraco.Web.UI/Umbraco/PartialViewMacros/Templates/EditProfile.cshtml @@ -2,13 +2,12 @@ @using System.Web.Mvc.Html @using ClientDependency.Core.Mvc -@using umbraco.cms.businesslogic.member @using Umbraco.Web @using Umbraco.Web.Models @using Umbraco.Web.Controllers @{ - var profileModel = new ProfileModel(); + var profileModel = Members.CreateProfileModel(); Html.EnableClientValidation(); Html.EnableUnobtrusiveJavaScript(); @@ -17,10 +16,11 @@ Html.RequiresJs("/umbraco_client/Application/JQuery/jquery.validate.unobtrusive.min.js"); } -@if (Member.IsLoggedOn()) -{ - @Html.RenderJsHere() +@*NOTE: This RenderJsHere code should be put on your main template page where the rest of your script tags are placed*@ +@Html.RenderJsHere() +@if (Members.IsLoggedIn()) +{ using (Html.BeginUmbracoForm("HandleUpdateProfile")) {
@@ -38,11 +38,11 @@ @Html.ValidationMessageFor(m => profileModel.Email)
- @for (var i = 0; i < profileModel.MemberProperties.Count; i++) + @foreach (var prop in profileModel.MemberProperties) { - @Html.LabelFor(m => profileModel.MemberProperties[i].Value, profileModel.MemberProperties[i].Name) - @Html.EditorFor(m => profileModel.MemberProperties[i].Value) - @Html.HiddenFor(m => profileModel.MemberProperties[i].Alias) + @Html.LabelFor(m => prop.Value, prop.Name) + @Html.EditorFor(m => prop.Value) + @Html.HiddenFor(m => prop.Alias)
} diff --git a/src/Umbraco.Web.UI/Umbraco/PartialViews/Templates/EditProfile.cshtml b/src/Umbraco.Web.UI/Umbraco/PartialViews/Templates/EditProfile.cshtml index ed7697721e..1994917f2f 100644 --- a/src/Umbraco.Web.UI/Umbraco/PartialViews/Templates/EditProfile.cshtml +++ b/src/Umbraco.Web.UI/Umbraco/PartialViews/Templates/EditProfile.cshtml @@ -1,14 +1,13 @@ -@inherits Umbraco.Web.Mvc.UmbracoTemplatePage +@inherits Umbraco.Web.Macros.PartialViewMacroPage @using System.Web.Mvc.Html @using ClientDependency.Core.Mvc -@using umbraco.cms.businesslogic.member @using Umbraco.Web @using Umbraco.Web.Models @using Umbraco.Web.Controllers @{ - var profileModel = new ProfileModel(); + var profileModel = Members.CreateProfileModel(); Html.EnableClientValidation(); Html.EnableUnobtrusiveJavaScript(); @@ -17,10 +16,11 @@ Html.RequiresJs("/umbraco_client/Application/JQuery/jquery.validate.unobtrusive.min.js"); } -@if (Member.IsLoggedOn()) -{ - @Html.RenderJsHere() +@*NOTE: This RenderJsHere code should be put on your main template page where the rest of your script tags are placed*@ +@Html.RenderJsHere() +@if (Members.IsLoggedIn()) +{ using (Html.BeginUmbracoForm("HandleUpdateProfile")) {
@@ -38,11 +38,11 @@ @Html.ValidationMessageFor(m => profileModel.Email)
- @for (var i = 0; i < profileModel.MemberProperties.Count; i++) + @foreach (var prop in profileModel.MemberProperties) { - @Html.LabelFor(m => profileModel.MemberProperties[i].Value, profileModel.MemberProperties[i].Name) - @Html.EditorFor(m => profileModel.MemberProperties[i].Value) - @Html.HiddenFor(m => profileModel.MemberProperties[i].Alias) + @Html.LabelFor(m => prop.Value, prop.Name) + @Html.EditorFor(m => prop.Value) + @Html.HiddenFor(m => prop.Alias)
} diff --git a/src/Umbraco.Web.UI/config/umbracoSettings.config b/src/Umbraco.Web.UI/config/umbracoSettings.config index a467040eba..6cced72c73 100644 --- a/src/Umbraco.Web.UI/config/umbracoSettings.config +++ b/src/Umbraco.Web.UI/config/umbracoSettings.config @@ -87,7 +87,7 @@ - throw - Throw an exception which can be caught by the global error handler defined in Application_OnError. If no such error handler is defined then you'll see the Yellow Screen Of Death (YSOD) error page. Note the error can also be handled by the umbraco.macro.Error event, where you can log/alarm with your own code and change the behaviour per event. --> - inline + throw