2018-06-29 19:52:40 +02:00
|
|
|
using System;
|
|
|
|
|
using System.Web.Mvc;
|
|
|
|
|
using Umbraco.Web.Models;
|
|
|
|
|
using Umbraco.Web.Mvc;
|
|
|
|
|
using Umbraco.Core.Security;
|
|
|
|
|
using Umbraco.Core;
|
2018-07-06 17:36:33 +02:00
|
|
|
using Umbraco.Core.Cache;
|
|
|
|
|
using Umbraco.Core.Logging;
|
|
|
|
|
using Umbraco.Core.Persistence;
|
|
|
|
|
using Umbraco.Core.Services;
|
2019-11-25 21:20:00 +11:00
|
|
|
using Umbraco.Web.Security;
|
2018-06-29 19:52:40 +02:00
|
|
|
|
|
|
|
|
namespace Umbraco.Web.Controllers
|
|
|
|
|
{
|
|
|
|
|
[MemberAuthorize]
|
|
|
|
|
public class UmbProfileController : SurfaceController
|
|
|
|
|
{
|
2018-07-06 17:36:33 +02:00
|
|
|
public UmbProfileController()
|
2019-01-21 15:57:48 +01:00
|
|
|
{ }
|
2018-07-06 17:36:33 +02:00
|
|
|
|
2019-02-14 12:40:45 +01:00
|
|
|
public UmbProfileController(IUmbracoContextAccessor umbracoContextAccessor, IUmbracoDatabaseFactory databaseFactory, ServiceContext services, AppCaches appCaches, ILogger logger, IProfilingLogger profilingLogger, UmbracoHelper umbracoHelper)
|
|
|
|
|
: base(umbracoContextAccessor, databaseFactory, services, appCaches, logger, profilingLogger, umbracoHelper)
|
2019-01-21 15:57:48 +01:00
|
|
|
{ }
|
2018-07-06 17:36:33 +02:00
|
|
|
|
2018-06-29 19:52:40 +02:00
|
|
|
[HttpPost]
|
2018-12-20 16:58:01 +11:00
|
|
|
[ValidateAntiForgeryToken]
|
2019-07-13 23:56:29 +02:00
|
|
|
[ValidateUmbracoFormRouteString]
|
2018-06-29 19:52:40 +02:00
|
|
|
public ActionResult HandleUpdateProfile([Bind(Prefix = "profileModel")] ProfileModel model)
|
|
|
|
|
{
|
|
|
|
|
if (ModelState.IsValid == false)
|
|
|
|
|
{
|
|
|
|
|
return CurrentUmbracoPage();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
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();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TempData["ProfileUpdateSuccess"] = true;
|
|
|
|
|
|
|
|
|
|
//if there is a specified path to redirect to then use it
|
|
|
|
|
if (model.RedirectUrl.IsNullOrWhiteSpace() == false)
|
|
|
|
|
{
|
|
|
|
|
return Redirect(model.RedirectUrl);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//redirect to current page by default
|
|
|
|
|
return RedirectToCurrentUmbracoPage();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|