Updates MembershipHelper to not change the email/name if the value has not changed. Updates the templates to show only validation summaries for their own values/prefixes. Fixes some underlying MVC methods that merge view state to ensure the prefixes work with validation summaries properly when not showing property level errors. Updates the Umb controllers to add model level validation msgs when failed.
This commit is contained in:
@@ -19,7 +19,8 @@ namespace Umbraco.Web.Controllers
|
||||
|
||||
if (Members.Login(model.Username, model.Password) == false)
|
||||
{
|
||||
ModelState.AddModelError("loginModel.Username", "Invalid username or password");
|
||||
//don't add a field level error, just model level
|
||||
ModelState.AddModelError("loginModel", "Invalid username or password");
|
||||
return CurrentUmbracoPage();
|
||||
}
|
||||
|
||||
|
||||
@@ -29,7 +29,8 @@ namespace Umbraco.Web.Controllers
|
||||
var updateAttempt = Members.UpdateMemberProfile(model);
|
||||
if (updateAttempt.Success == false)
|
||||
{
|
||||
ModelState.AddModelError("profileModel.Email", updateAttempt.Exception);
|
||||
//don't add a field level error, just model level
|
||||
ModelState.AddModelError("profileModel", updateAttempt.Exception.Message);
|
||||
return CurrentUmbracoPage();
|
||||
}
|
||||
|
||||
|
||||
@@ -64,10 +64,8 @@ namespace Umbraco.Web.Controllers
|
||||
case MembershipCreateStatus.InvalidProviderUserKey:
|
||||
case MembershipCreateStatus.DuplicateProviderUserKey:
|
||||
case MembershipCreateStatus.ProviderError:
|
||||
ModelState.AddModelError((model.UsernameIsEmail || model.Username == null)
|
||||
? "registerModel.Email"
|
||||
: "registerModel.Username",
|
||||
"An error occurred creating the member: " + status);
|
||||
//don't add a field level error, just model level
|
||||
ModelState.AddModelError("registerModel", "An error occurred creating the member: " + status);
|
||||
break;
|
||||
default:
|
||||
throw new ArgumentOutOfRangeException();
|
||||
|
||||
@@ -16,7 +16,9 @@ namespace Umbraco.Web
|
||||
{
|
||||
if (dictionary == null)
|
||||
return;
|
||||
foreach (var keyValuePair in dictionary.Where(keyValuePair => keyValuePair.Key.StartsWith(prefix + ".")))
|
||||
foreach (var keyValuePair in dictionary
|
||||
//It can either equal the prefix exactly (model level errors) or start with the prefix. (property level errors)
|
||||
.Where(keyValuePair => keyValuePair.Key == prefix || keyValuePair.Key.StartsWith(prefix + ".")))
|
||||
{
|
||||
state[keyValuePair.Key] = keyValuePair.Value;
|
||||
}
|
||||
|
||||
@@ -23,6 +23,8 @@ namespace Umbraco.Web.Mvc
|
||||
{
|
||||
var newContainer = new ViewDataContainer();
|
||||
newContainer.ViewData.ModelState.Merge(container.ViewData.ModelState, prefix);
|
||||
//change the html field name too
|
||||
newContainer.ViewData.TemplateInfo.HtmlFieldPrefix = prefix;
|
||||
return newContainer;
|
||||
}
|
||||
|
||||
|
||||
@@ -69,8 +69,12 @@ namespace Umbraco.Web.Security
|
||||
|
||||
try
|
||||
{
|
||||
//Use the membership provider to change the email since that is configured to do the checks to check for unique emails if that is configured.
|
||||
membershipUser = UpdateMember(membershipUser, Membership.Provider, model.Email);
|
||||
//check if the email needs to change
|
||||
if (model.Email.InvariantEquals(membershipUser.Email) == false)
|
||||
{
|
||||
//Use the membership provider to change the email since that is configured to do the checks to check for unique emails if that is configured.
|
||||
membershipUser = UpdateMember(membershipUser, Membership.Provider, model.Email);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
@@ -82,11 +86,10 @@ namespace Umbraco.Web.Security
|
||||
|
||||
//NOTE: If changing the username is a requirement, than that needs to be done via the IMember directly since MembershipProvider's natively do
|
||||
// not support changing a username!
|
||||
if (model.Name != null)
|
||||
if (model.Name != null && member.Name != model.Name)
|
||||
{
|
||||
member.Name = model.Name;
|
||||
}
|
||||
member.Email = model.Email;
|
||||
|
||||
if (model.MemberProperties != null)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user