Backports commit: Prefixed built in controllers to better avoid conflicts with people's custom code

Conflicts:
	src/Umbraco.Web.UI/Umbraco/PartialViewMacros/Templates/EditProfile.cshtml
	src/Umbraco.Web.UI/Umbraco/PartialViewMacros/Templates/Login.cshtml
	src/Umbraco.Web/Controllers/UmbLoginController.cs
	src/Umbraco.Web/Controllers/UmbLoginStatusController.cs
	src/Umbraco.Web/Controllers/UmbProfileController.cs
	src/Umbraco.Web/Controllers/UmbRegisterController.cs
	src/Umbraco.Web/Umbraco.Web.csproj
This commit is contained in:
Shannon
2014-01-28 13:47:16 +11:00
parent 677cc8c8fd
commit e4e76eb0bf
13 changed files with 17 additions and 17 deletions

View File

@@ -0,0 +1,66 @@
using System;
using System.Linq;
using System.Web.Mvc;
using System.Web.Security;
using System.Xml;
using umbraco.cms.businesslogic.member;
using Umbraco.Web.Models;
using Umbraco.Web.Mvc;
using Umbraco.Core.Security;
namespace Umbraco.Web.Controllers
{
public class UmbProfileController : SurfaceController
{
[HttpPost]
public ActionResult HandleUpdateProfile([Bind(Prefix = "profileModel")] ProfileModel model)
{
if (Membership.Provider.IsUmbracoMembershipProvider() == false)
{
throw new NotSupportedException("Profile editing with the " + typeof(UmbProfileController) + " is not supported when not using the default Umbraco membership provider");
}
if (ModelState.IsValid == false)
{
return CurrentUmbracoPage();
}
if (HttpContext.User == null || HttpContext.User.Identity.IsAuthenticated == false)
{
throw new NotSupportedException("No member is currently logged in");
}
var member = Services.MemberService.GetByUsername(HttpContext.User.Identity.Name);
if (member == null)
{
//this should never happen
throw new InvalidOperationException("No member found with username: " + HttpContext.User.Identity.Name);
}
if (model.Name != null)
{
member.Name = model.Name;
}
member.Email = model.Email;
member.Username = model.Email;
if (model.MemberProperties != null)
{
//TODO: Shouldn't we ensure that none of these properties are flagged as non-editable to the member??
foreach (var property in model.MemberProperties.Where(p => p.Value != null))
{
if (member.Properties.Contains(property.Alias))
{
member.Properties[property.Alias].Value = property.Value;
}
}
}
Services.MemberService.Save(member);
//reset the FormsAuth cookie since the username might have changed
FormsAuthentication.SetAuthCookie(member.Username, true);
//TODO: Why are we redirecting to home again here??
return Redirect("/");
}
}
}