update:路由权限判断放到userManager中
This commit is contained in:
@@ -21,5 +21,6 @@ namespace Ewide.Core
|
||||
Task<List<string>> GetUserRoleIdList();
|
||||
Task<List<SysRole>> GetUserRoleList(string userId);
|
||||
Task<List<SysRole>> GetUserRoleList();
|
||||
Task<List<string>> GetLoginPermissionList();
|
||||
}
|
||||
}
|
||||
@@ -6,6 +6,7 @@ using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using System.Collections.Generic;
|
||||
using Ewide.Core.Service;
|
||||
|
||||
namespace Ewide.Core
|
||||
{
|
||||
@@ -20,6 +21,7 @@ namespace Ewide.Core
|
||||
private readonly IRepository<SysEmp> _sysEmpRep; // 员工表
|
||||
private readonly IRepository<SysOrg> _sysOrgRep;
|
||||
private readonly IHttpContextAccessor _httpContextAccessor;
|
||||
private readonly ISysMenuService _sysMenuService;
|
||||
|
||||
public string UserId
|
||||
{
|
||||
@@ -52,7 +54,8 @@ namespace Ewide.Core
|
||||
IRepository<SysUserRole> sysUserRoleRep,
|
||||
IRepository<SysEmp> sysEmpRep,
|
||||
IRepository<SysOrg> sysOrgRep,
|
||||
IHttpContextAccessor httpContextAccessor)
|
||||
IHttpContextAccessor httpContextAccessor,
|
||||
ISysMenuService sysMenuService)
|
||||
{
|
||||
_sysUserRep = sysUserRep;
|
||||
_sysRoleRep = sysRoleRep;
|
||||
@@ -60,6 +63,7 @@ namespace Ewide.Core
|
||||
_sysEmpRep = sysEmpRep;
|
||||
_sysOrgRep = sysOrgRep;
|
||||
_httpContextAccessor = httpContextAccessor;
|
||||
_sysMenuService = sysMenuService;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -163,5 +167,10 @@ namespace Ewide.Core
|
||||
{
|
||||
return await GetUserRoleList(UserId);
|
||||
}
|
||||
|
||||
public Task<List<string>> GetLoginPermissionList()
|
||||
{
|
||||
return _sysMenuService.GetLoginPermissionList(UserId);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -69,7 +69,7 @@ namespace Ewide.Web.Core
|
||||
if (defalutRoute.Contains(routeName)) return true;
|
||||
|
||||
// 获取用户权限集合(按钮或API接口)
|
||||
var permissionList = await App.GetService<ISysMenuService>().GetLoginPermissionList(userManager.UserId);
|
||||
var permissionList = await userManager.GetLoginPermissionList();
|
||||
|
||||
// 检查授权
|
||||
return permissionList.Contains(routeName);
|
||||
|
||||
Reference in New Issue
Block a user