Files
Umbraco-CMS/src/Umbraco.Web/Controllers/UmbProfileController.cs

49 lines
1.6 KiB
C#
Raw Normal View History

using System;
using System.Linq;
2013-11-07 17:16:22 +01:00
using System.Web.Mvc;
using System.Web.Security;
2013-11-07 17:16:22 +01:00
using System.Xml;
using umbraco.cms.businesslogic.member;
using Umbraco.Web.Models;
using Umbraco.Web.Mvc;
using Umbraco.Core.Security;
using Umbraco.Core;
2013-11-07 17:16:22 +01:00
namespace Umbraco.Web.Controllers
{
public class UmbProfileController : SurfaceController
{
[HttpPost]
public ActionResult HandleUpdateProfile([Bind(Prefix = "profileModel")] ProfileModel model)
2013-11-07 17:16:22 +01:00
{
if (Membership.Provider.IsUmbracoMembershipProvider() == false)
2013-11-07 17:16:22 +01:00
{
throw new NotSupportedException("Profile editing with the " + typeof(UmbProfileController) + " is not supported when not using the default Umbraco membership provider");
}
2013-11-07 17:16:22 +01:00
if (ModelState.IsValid == false)
{
return CurrentUmbracoPage();
}
2013-11-07 17:16:22 +01:00
var updateAttempt = Members.UpdateMemberProfile(model);
if (updateAttempt.Success == false)
{
//don't add a field level error, just model level
ModelState.AddModelError("profileModel", updateAttempt.Exception.Message);
return CurrentUmbracoPage();
}
2013-11-07 17:16:22 +01:00
//if there is a specified path to redirect to then use it
if (model.RedirectUrl.IsNullOrWhiteSpace() == false)
{
return Redirect(model.RedirectUrl);
2013-11-07 17:16:22 +01:00
}
//redirect to current page by default
TempData.Add("ProfileUpdateSuccess", true);
return RedirectToCurrentUmbracoPage();
2013-11-07 17:16:22 +01:00
}
}
}