Browse Source

Sort roles by name in GetRolesAsync and GetAssignableRolesAsync methods

pull/22804/head
maliming 9 months ago
parent
commit
3e623ac2a5
No known key found for this signature in database GPG Key ID: A646B9CB645ECEA4
  1. 8
      modules/identity/src/Volo.Abp.Identity.Application/Volo/Abp/Identity/IdentityUserAppService.cs

8
modules/identity/src/Volo.Abp.Identity.Application/Volo/Abp/Identity/IdentityUserAppService.cs

@ -1,5 +1,6 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks; using System.Threading.Tasks;
using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Identity; using Microsoft.AspNetCore.Identity;
@ -58,7 +59,7 @@ public class IdentityUserAppService : IdentityAppServiceBase, IIdentityUserAppSe
{ {
//TODO: Should also include roles of the related OUs. //TODO: Should also include roles of the related OUs.
var roles = await UserRepository.GetRolesAsync(id); var roles = (await UserRepository.GetRolesAsync(id)).OrderBy(x => x.Name).ToList();
return new ListResultDto<IdentityRoleDto>( return new ListResultDto<IdentityRoleDto>(
ObjectMapper.Map<List<IdentityRole>, List<IdentityRoleDto>>(roles) ObjectMapper.Map<List<IdentityRole>, List<IdentityRoleDto>>(roles)
@ -68,9 +69,8 @@ public class IdentityUserAppService : IdentityAppServiceBase, IIdentityUserAppSe
[Authorize(IdentityPermissions.Users.Default)] [Authorize(IdentityPermissions.Users.Default)]
public virtual async Task<ListResultDto<IdentityRoleDto>> GetAssignableRolesAsync() public virtual async Task<ListResultDto<IdentityRoleDto>> GetAssignableRolesAsync()
{ {
var list = await RoleRepository.GetListAsync(); var list = (await RoleRepository.GetListAsync()).OrderBy(x => x.Name).ToList();
return new ListResultDto<IdentityRoleDto>( return new ListResultDto<IdentityRoleDto>(ObjectMapper.Map<List<IdentityRole>, List<IdentityRoleDto>>(list));
ObjectMapper.Map<List<IdentityRole>, List<IdentityRoleDto>>(list));
} }
[Authorize(IdentityPermissions.Users.Create)] [Authorize(IdentityPermissions.Users.Create)]

Loading…
Cancel
Save