diff --git a/src/Umbraco.Web/Models/Mapping/ContentModelMapper.cs b/src/Umbraco.Web/Models/Mapping/ContentModelMapper.cs index 7684636605..0c7dbffd49 100644 --- a/src/Umbraco.Web/Models/Mapping/ContentModelMapper.cs +++ b/src/Umbraco.Web/Models/Mapping/ContentModelMapper.cs @@ -221,8 +221,16 @@ namespace Umbraco.Web.Models.Mapping } var svc = _userService.Value; - var permissions = svc.GetPermissions(UmbracoContext.Current.Security.CurrentUser, source.Id) - .FirstOrDefault(); + var permissions = svc.GetPermissions( + //TODO: This is certainly not ideal usage here - perhaps the best way to deal with this in the future is + // with the IUmbracoContextAccessor. In the meantime, if used outside of a web app this will throw a null + // refrence exception :( + UmbracoContext.Current.Security.CurrentUser, + // Here we need to do a special check since this could be new content, in which case we need to get the permissions + // from the parent, not the existing one otherwise permissions would be coming from the root since Id is 0. + source.HasIdentity ? source.Id : source.ParentId) + .FirstOrDefault(); + if (permissions == null) { return Enumerable.Empty();