diff --git a/WebsitePanel/Sources/WebsitePanel.EnterpriseServer.Base/Common/BusinessErrorCodes.cs b/WebsitePanel/Sources/WebsitePanel.EnterpriseServer.Base/Common/BusinessErrorCodes.cs index f709a65b..703eae8a 100644 --- a/WebsitePanel/Sources/WebsitePanel.EnterpriseServer.Base/Common/BusinessErrorCodes.cs +++ b/WebsitePanel/Sources/WebsitePanel.EnterpriseServer.Base/Common/BusinessErrorCodes.cs @@ -62,6 +62,7 @@ namespace WebsitePanel.EnterpriseServer public const int ERROR_USER_WRONG_USERNAME = -109; public const int ERROR_USER_WRONG_PASSWORD = -110; public const int ERROR_INVALID_USER_NAME = -111; + public const int ERROR_USER_ACCOUNT_NOT_ENOUGH_PERMISSIONS = -112; #endregion #region Packages diff --git a/WebsitePanel/Sources/WebsitePanel.EnterpriseServer.Base/Security/DemandAccount.cs b/WebsitePanel/Sources/WebsitePanel.EnterpriseServer.Base/Security/DemandAccount.cs index a4807a65..720f6bd4 100644 --- a/WebsitePanel/Sources/WebsitePanel.EnterpriseServer.Base/Security/DemandAccount.cs +++ b/WebsitePanel/Sources/WebsitePanel.EnterpriseServer.Base/Security/DemandAccount.cs @@ -38,6 +38,10 @@ namespace WebsitePanel.EnterpriseServer NotDemo = 0x1, IsActive = 0x2, IsAdmin = 0x4, - IsReseller = 0x8 + IsReseller = 0x8, + IsPlatformCSR = 0x10, + IsPlatformHelpdesk = 0x20, + IsResellerCSR = 0x40, + IsResellerHelpdesk = 0x80, } } diff --git a/WebsitePanel/Sources/WebsitePanel.EnterpriseServer.Base/Users/UserRole.cs b/WebsitePanel/Sources/WebsitePanel.EnterpriseServer.Base/Users/UserRole.cs index a58e4289..c83a3abb 100644 --- a/WebsitePanel/Sources/WebsitePanel.EnterpriseServer.Base/Users/UserRole.cs +++ b/WebsitePanel/Sources/WebsitePanel.EnterpriseServer.Base/Users/UserRole.cs @@ -37,6 +37,10 @@ namespace WebsitePanel.EnterpriseServer { Administrator = 1, Reseller = 2, - User = 3 + User = 3, + ResellerCSR = 4, + PlatformCSR = 5, + ResellerHelpdesk = 6, + PlatformHelpdesk = 7 } } diff --git a/WebsitePanel/Sources/WebsitePanel.EnterpriseServer/Code/Common/SecurityContext.cs b/WebsitePanel/Sources/WebsitePanel.EnterpriseServer/Code/Common/SecurityContext.cs index fd457ab1..bd037cd7 100644 --- a/WebsitePanel/Sources/WebsitePanel.EnterpriseServer/Code/Common/SecurityContext.cs +++ b/WebsitePanel/Sources/WebsitePanel.EnterpriseServer/Code/Common/SecurityContext.cs @@ -45,6 +45,10 @@ namespace WebsitePanel.EnterpriseServer public const string ROLE_ADMINISTRATOR = "Administrator"; public const string ROLE_RESELLER = "Reseller"; public const string ROLE_USER = "User"; + public const string ROLE_PLATFORMCSR = "PlatformCSR"; + public const string ROLE_PLATFORMHELPDESK = "PlatformHelpdesk"; + public const string ROLE_RESELLERCSR = "ResellerCSR"; + public const string ROLE_RESELLERHELPDESK = "ResellerHelpdesk"; public const string CONTEXT_USER_INFO = "CONTEXT_USER_INFO"; @@ -62,8 +66,26 @@ namespace WebsitePanel.EnterpriseServer // set roles array List roles = new List(); roles.Add(SecurityContext.ROLE_USER); + + if (user.Role == UserRole.Reseller || user.Role == UserRole.Administrator || + user.Role == UserRole.PlatformHelpdesk || user.Role == UserRole.ResellerHelpdesk) + roles.Add(SecurityContext.ROLE_RESELLERHELPDESK); + + if (user.Role == UserRole.Reseller || user.Role == UserRole.Administrator || + user.Role == UserRole.PlatformCSR || user.Role == UserRole.ResellerCSR) + roles.Add(SecurityContext.ROLE_RESELLERCSR); + + if (user.Role == UserRole.Reseller || user.Role == UserRole.Administrator || + user.Role == UserRole.PlatformHelpdesk) + roles.Add(SecurityContext.ROLE_PLATFORMHELPDESK); + + if (user.Role == UserRole.Reseller || user.Role == UserRole.Administrator || + user.Role == UserRole.PlatformCSR) + roles.Add(SecurityContext.ROLE_PLATFORMCSR); + if (user.Role == UserRole.Reseller || user.Role == UserRole.Administrator) roles.Add(SecurityContext.ROLE_RESELLER); + if (user.Role == UserRole.Administrator) roles.Add(SecurityContext.ROLE_ADMINISTRATOR); @@ -152,9 +174,40 @@ namespace WebsitePanel.EnterpriseServer { // should make a check if the account has Admin role if (!User.IsInRole(ROLE_RESELLER)) - return BusinessErrorCodes.ERROR_USER_ACCOUNT_SHOULD_BE_RESELLER; + return BusinessErrorCodes.ERROR_USER_ACCOUNT_NOT_ENOUGH_PERMISSIONS; } + if ((demand & DemandAccount.IsPlatformCSR) == DemandAccount.IsPlatformCSR) + { + // should make a check if the account has Admin role + if (!User.IsInRole(ROLE_PLATFORMCSR)) + return BusinessErrorCodes.ERROR_USER_ACCOUNT_NOT_ENOUGH_PERMISSIONS; + } + + if ((demand & DemandAccount.IsPlatformHelpdesk) == DemandAccount.IsPlatformHelpdesk) + { + // should make a check if the account has Admin role + if (!User.IsInRole(ROLE_PLATFORMHELPDESK)) + return BusinessErrorCodes.ERROR_USER_ACCOUNT_NOT_ENOUGH_PERMISSIONS; + } + + + if ((demand & DemandAccount.IsResellerHelpdesk) == DemandAccount.IsResellerHelpdesk) + { + // should make a check if the account has Admin role + if (!User.IsInRole(ROLE_RESELLERHELPDESK)) + return BusinessErrorCodes.ERROR_USER_ACCOUNT_NOT_ENOUGH_PERMISSIONS; + } + + + if ((demand & DemandAccount.IsResellerCSR) == DemandAccount.IsResellerCSR) + { + // should make a check if the account has Admin role + if (!User.IsInRole(ROLE_RESELLERCSR)) + return BusinessErrorCodes.ERROR_USER_ACCOUNT_NOT_ENOUGH_PERMISSIONS; + } + + return 0; } diff --git a/WebsitePanel/Sources/WebsitePanel.EnterpriseServer/Code/Packages/PackageController.cs b/WebsitePanel/Sources/WebsitePanel.EnterpriseServer/Code/Packages/PackageController.cs index d336dfa0..7b2b322d 100644 --- a/WebsitePanel/Sources/WebsitePanel.EnterpriseServer/Code/Packages/PackageController.cs +++ b/WebsitePanel/Sources/WebsitePanel.EnterpriseServer/Code/Packages/PackageController.cs @@ -399,7 +399,7 @@ namespace WebsitePanel.EnterpriseServer // check account result.Result = SecurityContext.CheckAccount(DemandAccount.NotDemo | DemandAccount.IsActive - | DemandAccount.IsReseller); + | DemandAccount.IsResellerCSR); if (result.Result < 0) return result; // check if domain exists @@ -652,7 +652,7 @@ namespace WebsitePanel.EnterpriseServer { // check account result.Result = SecurityContext.CheckAccount(DemandAccount.NotDemo | DemandAccount.IsActive - | DemandAccount.IsReseller); + | DemandAccount.IsResellerCSR); if (result.Result < 0) return result; int packageId = -1; diff --git a/WebsitePanel/Sources/WebsitePanel.WebPortal/App_Data/WebsitePanel_Pages.config b/WebsitePanel/Sources/WebsitePanel.WebPortal/App_Data/WebsitePanel_Pages.config index d9a76036..be8e97cf 100644 --- a/WebsitePanel/Sources/WebsitePanel.WebPortal/App_Data/WebsitePanel_Pages.config +++ b/WebsitePanel/Sources/WebsitePanel.WebPortal/App_Data/WebsitePanel_Pages.config @@ -9,25 +9,25 @@ -