This commit is contained in:
MOHD ARIFF 2024-11-22 10:10:54 +08:00
parent 54b2affe28
commit 5569a72e68
3 changed files with 12 additions and 7 deletions

View File

@ -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;

View File

@ -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

View File

@ -46,7 +46,7 @@
</select>
</div>
<button class="btn col-md-3 f-icon mt-3 d-flex align-items-center" style="height: 36px; width: auto">
<i class=" fas fa-plus-square fa-lg"></i>&nbsp;Add method
<i class=" fas fa-plus-square fa-lg"></i>&ensp;Add method
</button>
</div>
<div class="form-group row">
@ -71,8 +71,7 @@
<div class="form-group row">
<label class="col-md-1">Role:</label>
<div class="col-md-6">
<select class="select2 form-select shadow-none mt-3" multiple="multiple" style="height: 36px; width: 100%" v-model="moduleData.methodAllowedUserType[index].allowedUserTypesArray
">
<select class="select2 form-select shadow-none mt-3" multiple="multiple" style="height: 36px; width: 100%" v-model="moduleData.methodAllowedUserType[index].allowedUserTypesArray">
<option v-for="(roleType, index) in roleData" :key="index" :value="roleType.name">{{ roleType.name }}</option>
</select>
</div>