Fixes: U4-4765 backoffice user section does not save password changes in v6.2
This commit is contained in:
@@ -323,7 +323,7 @@ namespace Umbraco.Core.Persistence.Repositories
|
||||
{
|
||||
changedCols.Add("LoginName");
|
||||
}
|
||||
// DO NOT update the password if it is null or empty
|
||||
// DO NOT update the password if it has not changed or if it is null or empty
|
||||
if (dirtyEntity.IsPropertyDirty("RawPasswordValue") && entity.RawPasswordValue.IsNullOrWhiteSpace() == false)
|
||||
{
|
||||
changedCols.Add("Password");
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Linq.Expressions;
|
||||
using Umbraco.Core;
|
||||
using Umbraco.Core.Models;
|
||||
using Umbraco.Core.Models.EntityBase;
|
||||
using Umbraco.Core.Models.Membership;
|
||||
@@ -170,8 +171,42 @@ namespace Umbraco.Core.Persistence.Repositories
|
||||
var userFactory = new UserFactory(entity.UserType);
|
||||
var userDto = userFactory.BuildDto(entity);
|
||||
|
||||
Database.Update(userDto);
|
||||
var dirtyEntity = (ICanBeDirty)entity;
|
||||
|
||||
//build list of columns to check for saving - we don't want to save the password if it hasn't changed!
|
||||
//List the columns to save, NOTE: would be nice to not have hard coded strings here but no real good way around that
|
||||
var colsToSave = new Dictionary<string, string>()
|
||||
{
|
||||
{"userDisabled", "IsApproved"},
|
||||
{"userNoConsole", "IsLockedOut"},
|
||||
{"userType", "UserType"},
|
||||
{"startStructureID", "StartContentId"},
|
||||
{"startMediaID", "StartMediaId"},
|
||||
{"userName", "Name"},
|
||||
{"userLogin", "Username"},
|
||||
{"userEmail", "Email"},
|
||||
{"userLanguage", "Language"},
|
||||
{"defaultToLiveEditing", "DefaultToLiveEditing"}
|
||||
};
|
||||
|
||||
//create list of properties that have changed
|
||||
var changedCols = colsToSave
|
||||
.Where(col => dirtyEntity.IsPropertyDirty(col.Value))
|
||||
.Select(col => col.Key)
|
||||
.ToList();
|
||||
|
||||
// DO NOT update the password if it has not changed or if it is null or empty
|
||||
if (dirtyEntity.IsPropertyDirty("RawPasswordValue") && entity.RawPasswordValue.IsNullOrWhiteSpace() == false)
|
||||
{
|
||||
changedCols.Add("userPassword");
|
||||
}
|
||||
|
||||
//only update the changed cols
|
||||
if (changedCols.Count > 0)
|
||||
{
|
||||
Database.Update(userDto, changedCols);
|
||||
}
|
||||
|
||||
//update the sections if they've changed
|
||||
var user = (User)entity;
|
||||
if (user.IsPropertyDirty("AllowedSections"))
|
||||
|
||||
@@ -113,11 +113,12 @@ namespace Umbraco.Core
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Determines whether the specified type is enumerable.
|
||||
/// </summary>
|
||||
/// <param name="type">The type.</param>
|
||||
internal static bool HasParameters(this MethodInfo method, params Type[] parameterTypes)
|
||||
/// <summary>
|
||||
/// Determines whether the specified type is enumerable.
|
||||
/// </summary>
|
||||
/// <param name="method">The type.</param>
|
||||
/// <param name="parameterTypes"></param>
|
||||
internal static bool HasParameters(this MethodInfo method, params Type[] parameterTypes)
|
||||
{
|
||||
var methodParameters = method.GetParameters().Select(parameter => parameter.ParameterType).ToArray();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user