Skip to content

Commit

Permalink
Fixing can't assign role
Browse files Browse the repository at this point in the history
  • Loading branch information
lampo1024 committed Feb 24, 2023
1 parent 0c4ae19 commit 5e25418
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 8 deletions.
8 changes: 3 additions & 5 deletions DncZeus.Api/Controllers/Api/V1/Rbac/RoleController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -310,16 +310,14 @@ public IActionResult FindListByUserGuid(Guid guid)
// x.DncRole.Code,
// x.DncRole.Name
//});
var userGuid = AuthContextService.CurrentUser.Guid;

var query = from urm in _dbContext.DncUserRoleMapping
join r in _dbContext.DncRole on urm.RoleCode equals r.Code
where urm.UserGuid == userGuid
select r;
where urm.UserGuid == guid
select new { r.Code };

var assignedRoles = query.Select(x => x.Code).ToList();
var roles = _dbContext.DncRole.Where(x =>
x.IsDeleted == CommonEnum.IsDeleted.No && x.Status == CommonEnum.Status.Normal)
var roles = _dbContext.DncRole.Where(x => x.IsDeleted == CommonEnum.IsDeleted.No && x.Status == CommonEnum.Status.Normal && !x.IsSuperAdministrator)
.Select(x => new { label = x.Name, key = x.Code })
.ToList();
response.SetData(new { roles, assignedRoles });
Expand Down
2 changes: 1 addition & 1 deletion DncZeus.Api/Controllers/Api/V1/Rbac/UserController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public IActionResult List(UserRequestPayload payload)
{
using (_dbContext)
{
var query = _dbContext.DncUser.AsQueryable();
var query = _dbContext.DncUser.Where(x => x.UserType != UserType.SuperAdministrator);
if (!string.IsNullOrEmpty(payload.Kw))
{
query = query.Where(x => x.LoginName.Contains(payload.Kw.Trim()) || x.DisplayName.Contains(payload.Kw.Trim()));
Expand Down
2 changes: 0 additions & 2 deletions DncZeus.Api/ViewModels/Rbac/DncUser/SaveUserRolesViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@

using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;

namespace DncZeus.Api.ViewModels.Rbac.DncUser
{
Expand Down

0 comments on commit 5e25418

Please sign in to comment.