mirror of
https://gitee.com/dotnetchina/OpenAuth.Net.git
synced 2025-09-20 02:29:24 +08:00
1、全面实现按登录用户动态加载按钮;
2、优化模块授权代码; 3、优化内部功能加载模块的权限控制,比如:拥有模块授权功能的用户给别人授权时,只能访问到自己拥有的模块;
This commit is contained in:
@@ -107,14 +107,26 @@ namespace OpenAuth.App
|
||||
|
||||
/// <summary>
|
||||
/// 加载特定用户的模块
|
||||
/// TODO:这里会加载用户及用户角色的所有模块,“为用户分配模块”功能会给人一种混乱的感觉,但可以接受
|
||||
/// </summary>
|
||||
/// <param name="userId">The user unique identifier.</param>
|
||||
public List<Module> LoadForUser(int userId)
|
||||
{
|
||||
//用户角色
|
||||
var userRoleIds =
|
||||
_relevanceRepository.Find(u => u.FirstId == userId && u.Key == "UserRole").Select(u => u.SecondId).ToList();
|
||||
|
||||
//用户角色与自己分配到的模块ID
|
||||
var moduleIds =
|
||||
_relevanceRepository.Find(u => u.FirstId == userId && u.Key == "UserModule")
|
||||
.Select(u => u.SecondId)
|
||||
.ToList();
|
||||
_relevanceRepository.Find(
|
||||
u =>
|
||||
(u.FirstId == userId && u.Key == "UserModule") ||
|
||||
(u.Key == "RoleModule" && userRoleIds.Contains(u.FirstId))).Select(u => u.SecondId).ToList();
|
||||
|
||||
//var moduleIds =
|
||||
// _relevanceRepository.Find(u => u.FirstId == userId && u.Key == "UserModule")
|
||||
// .Select(u => u.SecondId)
|
||||
// .ToList();
|
||||
if (!moduleIds.Any()) return new List<Module>();
|
||||
return _repository.Find(u => moduleIds.Contains(u.Id)).ToList();
|
||||
}
|
||||
|
Reference in New Issue
Block a user