Updates path check to use all assigned user start nodes that are combined by their groups and directly assigned values

This commit is contained in:
Shannon
2017-05-26 12:09:06 +10:00
parent 4337036358
commit 362b98509b
4 changed files with 35 additions and 11 deletions

View File

@@ -1,4 +1,5 @@
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Net;
@@ -10,7 +11,25 @@ using Umbraco.Core.Services;
namespace Umbraco.Core.Models
{
public static class UserExtensions
{
{
/// <summary>
/// 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> GetCombinedStartContentIds(this IUser user)
{
return user.StartContentIds.Concat(user.Groups.Select(x => x.StartContentId)).Distinct();
}
/// <summary>
/// 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)
{
return user.StartMediaIds.Concat(user.Groups.Select(x => x.StartMediaId)).Distinct();
}
/// <summary>
/// Tries to lookup the user's gravatar to see if the endpoint can be reached, if so it returns the valid URL
/// </summary>
@@ -115,7 +134,7 @@ namespace Umbraco.Core.Models
{
if (user == null) throw new ArgumentNullException("user");
if (content == null) throw new ArgumentNullException("content");
return HasPathAccess(content.Path, user.StartContentIds, Constants.System.RecycleBinContent);
return HasPathAccess(content.Path, user.GetCombinedStartContentIds().ToArray(), Constants.System.RecycleBinContent);
}
internal static bool HasPathAccess(string path, int[] startNodeIds, int recycleBinId)
@@ -159,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.StartMediaIds, Constants.System.RecycleBinMedia);
return HasPathAccess(media.Path, user.GetCombinedMediaContentIds().ToArray(), Constants.System.RecycleBinMedia);
}
/// <summary>