Skip to content
Permalink
Browse files

Cosmetic updates to security commands.

  • Loading branch information...
michaellwest committed Aug 7, 2019
1 parent 30a8f8d commit 451fcf1df28ab855d68c2d5d8bb4552e94a884fb
@@ -1,7 +1,6 @@
using System.Management.Automation;
using Sitecore.Data.Items;
using Sitecore.Security.AccessControl;
using Sitecore.Security.Accounts;
using Spe.Core.Extensions;
using Spe.Core.Utility;
using Spe.Core.Validation;
@@ -46,7 +45,7 @@ protected override void ProcessItem(Item item)
{
if (!this.TryParseAccessRight(AccessRight, out AccessRight accessRight)) return;

Account account = this.GetAccountFromIdentity(Identity);
var account = this.GetAccountFromIdentity(Identity);

var accessRule = AccessRule.Create(account, accessRight, PropagationType, SecurityPermission);
accessRules.Add(accessRule);
@@ -1,5 +1,4 @@
using System.Collections.Generic;
using System.Linq;
using System.Linq;
using System.Management.Automation;
using Sitecore.ContentSearch.Utilities;
using Sitecore.Data.Items;
@@ -14,7 +13,7 @@ public class GetItemAclCommand : BaseItemAclCommand

protected override void ProcessItem(Item item)
{
List<AccessRule> accessRights = item.Security.GetAccessRules().ToList();
var accessRights = item.Security.GetAccessRules().ToList();
if (ParameterSetName.StartsWith("Account ID"))
{
accessRights.Where(ar => ar.Account.Name.Equals(Identity.Name)).ForEach(WriteObject);
@@ -29,11 +29,9 @@ public class NewItemAclCommand : BaseCommand

protected override void ProcessRecord()
{
AccessRight accessRight;

if (!this.TryParseAccessRight(AccessRight, out accessRight)) return;
if (!this.TryParseAccessRight(AccessRight, out var accessRight)) return;

Account account = this.GetAccountFromIdentity(Identity);
var account = this.GetAccountFromIdentity(Identity);

var accessRule = AccessRule.Create(account, accessRight, PropagationType, SecurityPermission);
WriteObject(accessRule);
@@ -1,6 +1,5 @@
using System.Management.Automation;
using Sitecore.Data.Items;
using Sitecore.Security.AccessControl;
using Spe.Core.Extensions;
using Spe.Core.Validation;
using AuthorizationManager = Sitecore.Security.AccessControl.AuthorizationManager;
@@ -39,8 +38,7 @@ public class TestItemAclCommand : BaseItemAclCommand

protected override void ProcessItem(Item item)
{
AccessRight accessRight;
WriteObject(this.TryParseAccessRight(AccessRight, out accessRight) &&
WriteObject(this.TryParseAccessRight(AccessRight, out var accessRight) &&
AuthorizationManager.IsAllowed(item, accessRight, Identity));
}
}

0 comments on commit 451fcf1

Please sign in to comment.
You can’t perform that action at this time.