forked from ddrilling/AsbCloudServer
Fix UserService.GetNestedPermissions(). returns all permissions for all nested roles
This commit is contained in:
parent
fdc22f4f94
commit
007f7ac62e
@ -7,7 +7,7 @@ namespace AsbCloudApp.Services
|
||||
{
|
||||
IUserRoleService RoleService { get; }
|
||||
IEnumerable<PermissionDto> GetNestedPermissions(int idUser);
|
||||
IEnumerable<UserRoleDto> GetRolesByIdUser(int idUser);
|
||||
IEnumerable<UserRoleDto> GetRolesByIdUser(int idUser, int nestedLevel = 0);
|
||||
bool HasAnyRoleOf(int idUser, IEnumerable<string> roleNames);
|
||||
bool HasAnyRoleOf(int idUser, IEnumerable<int> roleIds);
|
||||
public bool HasPermission(int idUser, string permissionName);
|
||||
|
@ -8,3 +8,4 @@ SELECT timescaledb_pre_restore();
|
||||
SELECT timescaledb_post_restore();
|
||||
|
||||
|
||||
select * from t_telemetry_message ttm where id_event = 206;
|
@ -130,17 +130,17 @@ namespace AsbCloudInfrastructure.Services
|
||||
?.Select(r => r.Caption)
|
||||
.Distinct();
|
||||
|
||||
public IEnumerable<UserRoleDto> GetRolesByIdUser(int idUser)
|
||||
public IEnumerable<UserRoleDto> GetRolesByIdUser(int idUser, int nestedLevel = 0)
|
||||
{
|
||||
var roles = cacheRelationUserToRoles.Where(r => r.IdUser == idUser);
|
||||
if (roles?.Any() != true)
|
||||
return null;
|
||||
return roles.SelectMany(r => RoleService.GetNestedById(r.IdUserRole, 0));
|
||||
return roles.SelectMany(r => RoleService.GetNestedById(r.IdUserRole, nestedLevel));
|
||||
}
|
||||
|
||||
public IEnumerable<PermissionDto> GetNestedPermissions(int idUser)
|
||||
{
|
||||
var roles = GetRolesByIdUser(idUser);
|
||||
var roles = GetRolesByIdUser(idUser, 7);
|
||||
if(roles?.Any() != true)
|
||||
return null;
|
||||
var permissions = roles
|
||||
|
Loading…
Reference in New Issue
Block a user