fix(#I12QGH): 通过用户组给用户分配菜单无法登录

#Comment
comment #I12QGH
MongoDB 用户获取权限脚本未关联部门导致授权失败

#Issue
link https://gitee.com/LongbowEnterprise/dashboard/issues?id=I12QGH
This commit is contained in:
Argo Zhang 2019-09-28 15:39:26 +08:00
parent e347a26a2e
commit e01b89dacc
No known key found for this signature in database
GPG Key ID: 152E398953DDF19F
1 changed files with 9 additions and 1 deletions

View File

@ -80,11 +80,19 @@ namespace Bootstrap.DataAccess.MongoDB
var user = UserHelper.Retrieves().Cast<User>().FirstOrDefault(u => u.UserName.ToLowerInvariant() == userName.ToLowerInvariant());
if (user != null)
{
// 用户所属角色
var role = RoleHelper.Retrieves();
roles.AddRange(role.Where(r => user.Roles.Any(rl => rl == r.Id)).Select(r => r.RoleName));
// 用户所属部门 部门所属角色
GroupHelper.Retrieves().Cast<Group>().Where(group => user.Groups.Any(g => g == group.Id)).ToList().ForEach(g =>
{
roles.AddRange(role.Where(r => g.Roles.Any(rl => rl == r.Id)).Select(r => r.RoleName));
});
if (roles.Count == 0) roles.Add("Default");
}
return roles;
return roles.Distinct();
}
/// <summary>