From 9c428b7f0194197ab235c5799bb237d35b8b3a10 Mon Sep 17 00:00:00 2001 From: Warren Buckley Date: Wed, 12 Feb 2020 11:55:51 +0000 Subject: [PATCH 1/4] Bump version to 8.5.4 --- src/SolutionInfo.cs | 4 ++-- src/Umbraco.Web.UI/Umbraco.Web.UI.csproj | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/SolutionInfo.cs b/src/SolutionInfo.cs index 841e986f15..fda69955d8 100644 --- a/src/SolutionInfo.cs +++ b/src/SolutionInfo.cs @@ -18,5 +18,5 @@ using System.Resources; [assembly: AssemblyVersion("8.0.0")] // these are FYI and changed automatically -[assembly: AssemblyFileVersion("8.5.3")] -[assembly: AssemblyInformationalVersion("8.5.3")] +[assembly: AssemblyFileVersion("8.5.4")] +[assembly: AssemblyInformationalVersion("8.5.4")] diff --git a/src/Umbraco.Web.UI/Umbraco.Web.UI.csproj b/src/Umbraco.Web.UI/Umbraco.Web.UI.csproj index e12eb8d19b..b465f89cb5 100644 --- a/src/Umbraco.Web.UI/Umbraco.Web.UI.csproj +++ b/src/Umbraco.Web.UI/Umbraco.Web.UI.csproj @@ -345,9 +345,9 @@ False True - 8530 + 8540 / - http://localhost:8530 + http://localhost:8540 False False @@ -429,4 +429,4 @@ - + \ No newline at end of file From 6a6978d8da08ba6f6e74c6b948cab35b01a0041a Mon Sep 17 00:00:00 2001 From: Warren Buckley Date: Wed, 12 Feb 2020 10:41:31 +0000 Subject: [PATCH 2/4] Merge pull request #7627 from umbraco/v8/bugfix/AB4828-resetpassword-mail AB4828 - Reset Password Email (cherry picked from commit f00680bfe69d09f9eda123b8218b2508d8f5ca3d) --- .../Repositories/Implement/UserRepository.cs | 10 +++++++ .../Repositories/UserRepositoryTest.cs | 29 +++++++++++++++++++ 2 files changed, 39 insertions(+) diff --git a/src/Umbraco.Core/Persistence/Repositories/Implement/UserRepository.cs b/src/Umbraco.Core/Persistence/Repositories/Implement/UserRepository.cs index 96abc37662..3be5102b83 100644 --- a/src/Umbraco.Core/Persistence/Repositories/Implement/UserRepository.cs +++ b/src/Umbraco.Core/Persistence/Repositories/Implement/UserRepository.cs @@ -557,6 +557,16 @@ ORDER BY colName"; } } + // If userlogin or the email has changed then need to reset security stamp + if (changedCols.Contains("userLogin") || changedCols.Contains("userEmail")) + { + userDto.EmailConfirmedDate = null; + userDto.SecurityStampToken = entity.SecurityStamp = Guid.NewGuid().ToString(); + + changedCols.Add("emailConfirmedDate"); + changedCols.Add("securityStampToken"); + } + //only update the changed cols if (changedCols.Count > 0) { diff --git a/src/Umbraco.Tests/Persistence/Repositories/UserRepositoryTest.cs b/src/Umbraco.Tests/Persistence/Repositories/UserRepositoryTest.cs index 3e5919d7f3..a5787d59e4 100644 --- a/src/Umbraco.Tests/Persistence/Repositories/UserRepositoryTest.cs +++ b/src/Umbraco.Tests/Persistence/Repositories/UserRepositoryTest.cs @@ -409,6 +409,35 @@ namespace Umbraco.Tests.Persistence.Repositories } } + [Test] + public void Can_Invalidate_SecurityStamp_On_Username_Change() + { + // Arrange + var provider = TestObjects.GetScopeProvider(Logger); + using (var scope = provider.CreateScope()) + { + var repository = CreateRepository(provider); + var userGroupRepository = CreateUserGroupRepository(provider); + + var user = CreateAndCommitUserWithGroup(repository, userGroupRepository); + var originalSecurityStamp = user.SecurityStamp; + + // Ensure when user generated a security stamp is present + Assert.That(user.SecurityStamp, Is.Not.Null); + Assert.That(user.SecurityStamp, Is.Not.Empty); + + // Update username + user.Username = user.Username + "UPDATED"; + repository.Save(user); + + // Get the user + var updatedUser = repository.Get(user.Id); + + // Ensure the Security Stamp is invalidated & no longer the same + Assert.AreNotEqual(originalSecurityStamp, updatedUser.SecurityStamp); + } + } + private void AssertPropertyValues(IUser updatedItem, IUser originalUser) { Assert.That(updatedItem.Id, Is.EqualTo(originalUser.Id)); From 2d3388d6d3ff6882c9e7b9e92f717ece03834fbe Mon Sep 17 00:00:00 2001 From: Warren Buckley Date: Thu, 12 Mar 2020 11:50:02 +0000 Subject: [PATCH 3/4] Update dependency for 8.5.5 --- build/NuSpecs/UmbracoCms.Web.nuspec | 2 +- src/SolutionInfo.cs | 6 +++--- src/Umbraco.Web.UI/Umbraco.Web.UI.csproj | 6 +++--- src/Umbraco.Web/Umbraco.Web.csproj | 4 ++-- 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/build/NuSpecs/UmbracoCms.Web.nuspec b/build/NuSpecs/UmbracoCms.Web.nuspec index 658d2f0672..7984ec72ff 100644 --- a/build/NuSpecs/UmbracoCms.Web.nuspec +++ b/build/NuSpecs/UmbracoCms.Web.nuspec @@ -25,7 +25,7 @@ not want this to happen as the alpha of the next major is, really, the next major already. --> - + diff --git a/src/SolutionInfo.cs b/src/SolutionInfo.cs index fda69955d8..8cc33a4713 100644 --- a/src/SolutionInfo.cs +++ b/src/SolutionInfo.cs @@ -2,7 +2,7 @@ using System.Resources; [assembly: AssemblyCompany("Umbraco")] -[assembly: AssemblyCopyright("Copyright © Umbraco 2019")] +[assembly: AssemblyCopyright("Copyright © Umbraco 2020")] [assembly: AssemblyTrademark("")] [assembly: AssemblyCulture("")] @@ -18,5 +18,5 @@ using System.Resources; [assembly: AssemblyVersion("8.0.0")] // these are FYI and changed automatically -[assembly: AssemblyFileVersion("8.5.4")] -[assembly: AssemblyInformationalVersion("8.5.4")] +[assembly: AssemblyFileVersion("8.5.5")] +[assembly: AssemblyInformationalVersion("8.5.5")] diff --git a/src/Umbraco.Web.UI/Umbraco.Web.UI.csproj b/src/Umbraco.Web.UI/Umbraco.Web.UI.csproj index b465f89cb5..b38e50a6ca 100644 --- a/src/Umbraco.Web.UI/Umbraco.Web.UI.csproj +++ b/src/Umbraco.Web.UI/Umbraco.Web.UI.csproj @@ -86,7 +86,7 @@ - + @@ -345,9 +345,9 @@ False True - 8540 + 8550 / - http://localhost:8540 + http://localhost:8550 False False diff --git a/src/Umbraco.Web/Umbraco.Web.csproj b/src/Umbraco.Web/Umbraco.Web.csproj index 5d29e53d4a..0ed55720d0 100755 --- a/src/Umbraco.Web/Umbraco.Web.csproj +++ b/src/Umbraco.Web/Umbraco.Web.csproj @@ -61,7 +61,7 @@ - + @@ -1279,4 +1279,4 @@ - + \ No newline at end of file From 0a45f4afefa93dd821d0a5f6f772d6ab422894af Mon Sep 17 00:00:00 2001 From: Shannon Deminick Date: Fri, 13 Mar 2020 20:52:38 +1100 Subject: [PATCH 4/4] Fixes issue with deep cloning property values (#7795) --- src/Umbraco.Core/Models/Property.cs | 36 +++++++++++++++- .../Services/ContentServiceTests.cs | 43 +++++++++++++++++++ 2 files changed, 78 insertions(+), 1 deletion(-) diff --git a/src/Umbraco.Core/Models/Property.cs b/src/Umbraco.Core/Models/Property.cs index 76349823ac..f51f70faf6 100644 --- a/src/Umbraco.Core/Models/Property.cs +++ b/src/Umbraco.Core/Models/Property.cs @@ -50,7 +50,7 @@ namespace Umbraco.Core.Models /// /// Represents a property value. /// - public class PropertyValue + public class PropertyValue : IEquatable { // TODO: Either we allow change tracking at this class level, or we add some special change tracking collections to the Property // class to deal with change tracking which variants have changed @@ -95,6 +95,26 @@ namespace Umbraco.Core.Models /// public PropertyValue Clone() => new PropertyValue { _culture = _culture, _segment = _segment, PublishedValue = PublishedValue, EditedValue = EditedValue }; + + public override bool Equals(object obj) + { + return Equals(obj as PropertyValue); + } + + public bool Equals(PropertyValue other) + { + return other != null && + _culture == other._culture && + _segment == other._segment; + } + + public override int GetHashCode() + { + var hashCode = -1254204277; + hashCode = hashCode * -1521134295 + EqualityComparer.Default.GetHashCode(_culture); + hashCode = hashCode * -1521134295 + EqualityComparer.Default.GetHashCode(_segment); + return hashCode; + } } private static readonly DelegateEqualityComparer PropertyValueComparer = new DelegateEqualityComparer( @@ -338,6 +358,20 @@ namespace Umbraco.Core.Models var clonedEntity = (Property)clone; + //manually clone _values, _pvalue, _vvalues + clonedEntity._values = _values?.Select(x => x.Clone()).ToList(); // all values get copied + clonedEntity._pvalue = _pvalue?.Clone(); + // the tricky part here is that _values contains ALL values including the values in the _vvalues + // dictionary and they are by reference which is why we have equality overloads on PropertyValue + if (clonedEntity._vvalues != null) + { + clonedEntity._vvalues = new Dictionary(); + foreach (var item in _vvalues) + { + clonedEntity._vvalues[item.Key] = clonedEntity._values.First(x => x.Equals(item.Value)); + } + } + //need to manually assign since this is a readonly property clonedEntity.PropertyType = (PropertyType) PropertyType.DeepClone(); } diff --git a/src/Umbraco.Tests/Services/ContentServiceTests.cs b/src/Umbraco.Tests/Services/ContentServiceTests.cs index 92d2a68472..c93964a2ff 100644 --- a/src/Umbraco.Tests/Services/ContentServiceTests.cs +++ b/src/Umbraco.Tests/Services/ContentServiceTests.cs @@ -1890,6 +1890,49 @@ namespace Umbraco.Tests.Services //Assert.AreNotEqual(content.Name, copy.Name); } + [Test] + public void Can_Copy_And_Modify_Content_With_Events() + { + // see https://github.com/umbraco/Umbraco-CMS/issues/5513 + + TypedEventHandler> copying = (sender, args) => + { + args.Copy.SetValue("title", "1"); + args.Original.SetValue("title", "2"); + }; + + TypedEventHandler> copied = (sender, args) => + { + var copyVal = args.Copy.GetValue("title"); + var origVal = args.Original.GetValue("title"); + + Assert.AreEqual("1", copyVal); + Assert.AreEqual("2", origVal); + }; + + try + { + var contentService = ServiceContext.ContentService; + + ContentService.Copying += copying; + ContentService.Copied += copied; + + var contentType = MockedContentTypes.CreateSimpleContentType(); + ServiceContext.ContentTypeService.Save(contentType); + var content = MockedContent.CreateSimpleContent(contentType); + content.SetValue("title", "New Value"); + contentService.Save(content); + + var copy = contentService.Copy(content, content.ParentId, false, Constants.Security.SuperUserId); + Assert.AreEqual("1", copy.GetValue("title")); + } + finally + { + ContentService.Copying -= copying; + ContentService.Copied -= copied; + } + } + [Test] public void Can_Copy_Recursive() {