diff --git a/Controllers/AdminController.cs b/Controllers/AdminController.cs index ad2d267..646bcc5 100644 --- a/Controllers/AdminController.cs +++ b/Controllers/AdminController.cs @@ -6,7 +6,7 @@ using System.Diagnostics; namespace PSTW_CentralSystem.Controllers { - [Authorize(Policy = "RoleModulePolicy")] + //[Authorize(Policy = "RoleModulePolicy")] public class AdminController : Controller { private readonly AuthDBContext _authDbContext; diff --git a/CustomPolicy/RoleModulePolicy.cs b/CustomPolicy/RoleModulePolicy.cs index 29f3e41..bd0cb1e 100644 --- a/CustomPolicy/RoleModulePolicy.cs +++ b/CustomPolicy/RoleModulePolicy.cs @@ -64,7 +64,13 @@ namespace PSTW_CentralSystem.CustomPolicy void checkModuleExistOrNot() { - if (registeredModule == null) + + if ( moduleName == "Admin") + { + context.Fail(); + return; + } + else if (registeredModule == null) { context.Fail(); return; @@ -105,13 +111,13 @@ namespace PSTW_CentralSystem.CustomPolicy void checkMethodAndRole() { + // Load all ModuleSettings and process them in memory var moduleSettings = _authDBContext.ModuleSettings.AsEnumerable(); // Check if the method exists in the module settings // Check if the method exists in the module settings - var isMethodExist = moduleSettings - .FirstOrDefault(m => m.MethodAllowedUserType?.Any(mt => mt.MethodName == pageName) == true); + var isMethodExist = moduleSettings.FirstOrDefault(m => m.MethodAllowedUserType?.Any(mt => mt.MethodName == pageName) == true); if (isMethodExist != null) // Check if the method exists which means method is registered diff --git a/Views/Admin/ModuleSetting.cshtml b/Views/Admin/ModuleSetting.cshtml index 5f5ae4f..e0daeb7 100644 --- a/Views/Admin/ModuleSetting.cshtml +++ b/Views/Admin/ModuleSetting.cshtml @@ -46,7 +46,7 @@
@@ -71,8 +71,7 @@
-