From eddd643249676976502bc10e05c105db36df8fa4 Mon Sep 17 00:00:00 2001 From: Shannon Date: Mon, 13 Jul 2015 15:52:21 +0200 Subject: [PATCH] ensures that when setting the PropertyType's property on a PropertyGroup that the PropertyGroupId is set and updates an auth method to ensure that the correct identity type is returned. --- src/Umbraco.Core/Models/PropertyGroup.cs | 8 ++++++++ src/Umbraco.Web/Editors/BackOfficeController.cs | 2 +- src/Umbraco.Web/Security/WebSecurity.cs | 15 +++++++++++++-- 3 files changed, 22 insertions(+), 3 deletions(-) diff --git a/src/Umbraco.Core/Models/PropertyGroup.cs b/src/Umbraco.Core/Models/PropertyGroup.cs index 94e46e1ed1..7976a7eac6 100644 --- a/src/Umbraco.Core/Models/PropertyGroup.cs +++ b/src/Umbraco.Core/Models/PropertyGroup.cs @@ -1,6 +1,7 @@ using System; using System.Collections.Specialized; using System.Diagnostics; +using System.Linq; using System.Reflection; using System.Runtime.Serialization; using Umbraco.Core.Models.EntityBase; @@ -105,6 +106,13 @@ namespace Umbraco.Core.Models set { _propertyTypes = value; + + //since we're adding this collection to this group, we need to ensure that all the lazy values are set. + foreach (var propertyType in _propertyTypes) + { + propertyType.PropertyGroupId = new Lazy(() => this.Id); + } + _propertyTypes.CollectionChanged += PropertyTypesChanged; } } diff --git a/src/Umbraco.Web/Editors/BackOfficeController.cs b/src/Umbraco.Web/Editors/BackOfficeController.cs index 0be884f5b4..ea4a21d840 100644 --- a/src/Umbraco.Web/Editors/BackOfficeController.cs +++ b/src/Umbraco.Web/Editors/BackOfficeController.cs @@ -105,7 +105,7 @@ namespace Umbraco.Web.Editors { var cultureInfo = string.IsNullOrWhiteSpace(culture) //if the user is logged in, get their culture, otherwise default to 'en' - ? User.Identity.IsAuthenticated + ? Security.IsAuthenticated() ? Security.CurrentUser.GetUserCulture(Services.TextService) : CultureInfo.GetCultureInfo("en") : CultureInfo.GetCultureInfo(culture); diff --git a/src/Umbraco.Web/Security/WebSecurity.cs b/src/Umbraco.Web/Security/WebSecurity.cs index 463b2c84e3..d3d6f76999 100644 --- a/src/Umbraco.Web/Security/WebSecurity.cs +++ b/src/Umbraco.Web/Security/WebSecurity.cs @@ -323,7 +323,7 @@ namespace Umbraco.Web.Security // since the authentication happens in the Module, that authentication also checks the ticket expiry. We don't // need to check it a second time because that requires another decryption phase and nothing can tamper with it during the request. - if (_httpContext.User.Identity.IsAuthenticated == false) + if (IsAuthenticated() == false) { //There is no user if (throwExceptions) throw new InvalidOperationException("The user has no umbraco contextid - try logging in"); @@ -403,11 +403,22 @@ namespace Umbraco.Web.Security { } } - + + /// + /// Ensures that a back office user is logged in + /// + /// + public bool IsAuthenticated() + { + return _httpContext.User.Identity.IsAuthenticated && _httpContext.GetCurrentIdentity(false) != null; + } + protected override void DisposeResources() { _httpContext = null; _applicationContext = null; } + + } }