From 8b11b72d4d684a22c9908deff618fb037487b073 Mon Sep 17 00:00:00 2001 From: Rick Falkvinge Date: Sat, 2 May 2015 12:19:09 +0200 Subject: [PATCH] Authority checks for org/geo combo --- Site5/Automation/SwarmFunctions.aspx.cs | 16 +++++++++++++++- Site5/Pages/v5/Admin/OrgStaffing.aspx.cs | 4 ++-- 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/Site5/Automation/SwarmFunctions.aspx.cs b/Site5/Automation/SwarmFunctions.aspx.cs index a0a32231..a1c1a9a8 100644 --- a/Site5/Automation/SwarmFunctions.aspx.cs +++ b/Site5/Automation/SwarmFunctions.aspx.cs @@ -39,8 +39,22 @@ namespace Swarmops.Frontend.Automation { throw new UnauthorizedAccessException(); } - if (!authData.Authority.HasAccess (new Access (AccessAspect.Administration))) + if (position.PositionLevel == PositionLevel.SystemWide && !authData.Authority.HasAccess (new Access (AccessAspect.Administration))) { + // Authority check for systemwide + throw new UnauthorizedAccessException(); + } + if ((position.GeographyId == Geography.RootIdentity || position.GeographyId == 0) && + !authData.Authority.HasAccess (new Access (authData.CurrentOrganization, AccessAspect.Administration))) + { + // Authority check for org-global + throw new UnauthorizedAccessException(); + } + if ( + !authData.Authority.HasAccess (new Access (authData.CurrentOrganization, geography, + AccessAspect.Administration))) + { + // Authority check for org/geo combo throw new UnauthorizedAccessException(); } diff --git a/Site5/Pages/v5/Admin/OrgStaffing.aspx.cs b/Site5/Pages/v5/Admin/OrgStaffing.aspx.cs index 1afdad5b..90deb887 100644 --- a/Site5/Pages/v5/Admin/OrgStaffing.aspx.cs +++ b/Site5/Pages/v5/Admin/OrgStaffing.aspx.cs @@ -45,9 +45,9 @@ namespace Swarmops.Frontend.Pages.v5.Admin if (orgPositions.Count == 0) { - // not initalized. Initialize. + // not initalized. Initialize. Assume nonprofit. - Positions.CreateOrganizationDefaultPositions (CurrentOrganization); + Positions.CreateOrganizationDefaultPositions (CurrentOrganization, PositionTitle.Nonprofit); }