Ensures the user's combined start nodes are used when checking path access
This commit is contained in:
@@ -25,7 +25,7 @@ namespace Umbraco.Core.Models
|
||||
/// Returns all of the user's assigned start node ids based on ids assigned directly to the IUser object and it's groups
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public static IEnumerable<int> GetCombinedMediaContentIds(this IUser user)
|
||||
public static IEnumerable<int> GetCombinedStartMediaIds(this IUser user)
|
||||
{
|
||||
return user.StartMediaIds.Concat(user.Groups.Select(x => x.StartMediaId)).Distinct();
|
||||
}
|
||||
@@ -136,10 +136,10 @@ namespace Umbraco.Core.Models
|
||||
if (content == null) throw new ArgumentNullException("content");
|
||||
return HasPathAccess(content.Path, user.GetCombinedStartContentIds().ToArray(), Constants.System.RecycleBinContent);
|
||||
}
|
||||
|
||||
|
||||
internal static bool HasPathAccess(string path, int[] startNodeIds, int recycleBinId)
|
||||
{
|
||||
Mandate.ParameterNotNullOrEmpty(path, "path");
|
||||
if (string.IsNullOrWhiteSpace(path)) throw new ArgumentException("Value cannot be null or whitespace.", "path");
|
||||
|
||||
var formattedPath = "," + path + ",";
|
||||
var formattedRecycleBinId = "," + recycleBinId.ToInvariantString() + ",";
|
||||
@@ -178,7 +178,7 @@ namespace Umbraco.Core.Models
|
||||
{
|
||||
if (user == null) throw new ArgumentNullException("user");
|
||||
if (media == null) throw new ArgumentNullException("media");
|
||||
return HasPathAccess(media.Path, user.GetCombinedMediaContentIds().ToArray(), Constants.System.RecycleBinMedia);
|
||||
return HasPathAccess(media.Path, user.GetCombinedStartMediaIds().ToArray(), Constants.System.RecycleBinMedia);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -802,12 +802,12 @@ namespace Umbraco.Web.Editors
|
||||
var hasPathAccess = (nodeId == Constants.System.Root)
|
||||
? UserExtensions.HasPathAccess(
|
||||
Constants.System.Root.ToInvariantString(),
|
||||
user.StartContentIds,
|
||||
user.GetCombinedStartContentIds().ToArray(),
|
||||
Constants.System.RecycleBinContent)
|
||||
: (nodeId == Constants.System.RecycleBinContent)
|
||||
? UserExtensions.HasPathAccess(
|
||||
Constants.System.RecycleBinContent.ToInvariantString(),
|
||||
user.StartContentIds,
|
||||
user.GetCombinedStartContentIds().ToArray(),
|
||||
Constants.System.RecycleBinContent)
|
||||
: user.HasPathAccess(contentItem);
|
||||
|
||||
|
||||
@@ -887,12 +887,12 @@ namespace Umbraco.Web.Editors
|
||||
var hasPathAccess = (nodeId == Constants.System.Root)
|
||||
? UserExtensions.HasPathAccess(
|
||||
Constants.System.Root.ToInvariantString(),
|
||||
user.StartMediaIds,
|
||||
user.GetCombinedStartMediaIds().ToArray(),
|
||||
Constants.System.RecycleBinMedia)
|
||||
: (nodeId == Constants.System.RecycleBinMedia)
|
||||
? UserExtensions.HasPathAccess(
|
||||
Constants.System.RecycleBinMedia.ToInvariantString(),
|
||||
user.StartMediaIds,
|
||||
user.GetCombinedStartMediaIds().ToArray(),
|
||||
Constants.System.RecycleBinMedia)
|
||||
: user.HasPathAccess(media);
|
||||
|
||||
|
||||
@@ -41,7 +41,7 @@ namespace Umbraco.Web.WebApi.Filters
|
||||
|
||||
protected virtual int[] GetUserStartNodes(IUser user)
|
||||
{
|
||||
return user.StartMediaIds;
|
||||
return user.GetCombinedStartMediaIds().ToArray();
|
||||
}
|
||||
|
||||
protected virtual int RecycleBinId
|
||||
|
||||
Reference in New Issue
Block a user