Skip to content

Commit 16f0038

Browse files
committed
Fix permission not showing issue in super-admin panel
1 parent 76cd34b commit 16f0038

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

Controllers/SuperAdmin/UserRolesController.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,24 +46,24 @@ public async Task<IActionResult> Manage(Guid userId)
4646
{
4747
ViewBag.userId = userId;
4848
User user = await _userManager.FindByIdAsync(userId.ToString());
49+
IList<string> userRoleList = await _userManager.GetRolesAsync(user);
4950
if (user == null)
5051
{
5152
ViewBag.ErrorMessage = $"User with Id = {userId} cannot be found";
5253
return View("NotFound");
5354
}
5455
ViewBag.UserName = user.UserName;
5556
List<ManageUserRolesViewModel> model = new List<ManageUserRolesViewModel>();
57+
5658
foreach (Role role in _roleManager.Roles)
5759
{
5860
ManageUserRolesViewModel userRolesViewModel = new ManageUserRolesViewModel
5961
{
6062
RoleId = role.Id,
6163
RoleName = role.Name
6264
};
63-
var b = user.Roles.Where(x => x.RoleId == role.Id).FirstOrDefault();
64-
var a = await _userManager.IsInRoleAsync(user, role.Name);
65-
66-
if (await _userManager.IsInRoleAsync(user, role.Name))
65+
//if (await _userManager.IsInRoleAsync(user, role.Name))
66+
if(userRoleList.Contains(role.Name))
6767
{
6868
userRolesViewModel.Selected = true;
6969
}

0 commit comments

Comments
 (0)