|
|
|
@ -6,7 +6,7 @@ using System.Security.Claims; |
|
|
|
using System.Threading; |
|
|
|
using System.Threading.Tasks; |
|
|
|
using Microsoft.EntityFrameworkCore; |
|
|
|
using Microsoft.EntityFrameworkCore.Internal; |
|
|
|
using Microsoft.EntityFrameworkCore.Internal; |
|
|
|
using Volo.Abp.Domain.Repositories.EntityFrameworkCore; |
|
|
|
using Volo.Abp.EntityFrameworkCore; |
|
|
|
|
|
|
|
@ -20,7 +20,7 @@ namespace Volo.Abp.Identity.EntityFrameworkCore |
|
|
|
} |
|
|
|
|
|
|
|
public virtual async Task<IdentityUser> FindByNormalizedUserNameAsync( |
|
|
|
string normalizedUserName, |
|
|
|
string normalizedUserName, |
|
|
|
bool includeDetails = true, |
|
|
|
CancellationToken cancellationToken = default) |
|
|
|
{ |
|
|
|
@ -33,15 +33,15 @@ namespace Volo.Abp.Identity.EntityFrameworkCore |
|
|
|
} |
|
|
|
|
|
|
|
public virtual async Task<List<string>> GetRoleNamesAsync( |
|
|
|
Guid id, |
|
|
|
Guid id, |
|
|
|
CancellationToken cancellationToken = default) |
|
|
|
{ |
|
|
|
var query = from userRole in DbContext.Set<IdentityUserRole>() |
|
|
|
join role in DbContext.Roles on userRole.RoleId equals role.Id |
|
|
|
where userRole.UserId == id |
|
|
|
select role.Name; |
|
|
|
var organizationUnitIds = DbContext.Set<IdentityUserOrganizationUnit>().Where(q => q.UserId == id).Select(q => q.OrganizationUnitId).ToArray(); |
|
|
|
var organizationRoleIds = DbContext.Set<OrganizationUnitRole>().Where(our => organizationUnitIds.Contains(our.OrganizationUnitId)).Select(r => r.RoleId).ToArray(); |
|
|
|
select role.Name; |
|
|
|
var organizationUnitIds = DbContext.Set<IdentityUserOrganizationUnit>().Where(q => q.UserId == id).Select(q => q.OrganizationUnitId).ToArray(); |
|
|
|
var organizationRoleIds = DbContext.Set<OrganizationUnitRole>().Where(our => organizationUnitIds.Contains(our.OrganizationUnitId)).Select(r => r.RoleId).ToArray(); |
|
|
|
var orgUnitRoleNameQuery = DbContext.Roles.Where(r => organizationRoleIds.Contains(r.Id)).Select(n => n.Name); |
|
|
|
var resultQuery = query.Union(orgUnitRoleNameQuery); |
|
|
|
return await resultQuery.ToListAsync(GetCancellationToken(cancellationToken)); |
|
|
|
@ -61,8 +61,8 @@ namespace Volo.Abp.Identity.EntityFrameworkCore |
|
|
|
} |
|
|
|
|
|
|
|
public virtual async Task<IdentityUser> FindByLoginAsync( |
|
|
|
string loginProvider, |
|
|
|
string providerKey, |
|
|
|
string loginProvider, |
|
|
|
string providerKey, |
|
|
|
bool includeDetails = true, |
|
|
|
CancellationToken cancellationToken = default) |
|
|
|
{ |
|
|
|
@ -94,7 +94,7 @@ namespace Volo.Abp.Identity.EntityFrameworkCore |
|
|
|
} |
|
|
|
|
|
|
|
public virtual async Task<List<IdentityUser>> GetListByNormalizedRoleNameAsync( |
|
|
|
string normalizedRoleName, |
|
|
|
string normalizedRoleName, |
|
|
|
bool includeDetails = false, |
|
|
|
CancellationToken cancellationToken = default) |
|
|
|
{ |
|
|
|
@ -114,10 +114,10 @@ namespace Volo.Abp.Identity.EntityFrameworkCore |
|
|
|
} |
|
|
|
|
|
|
|
public virtual async Task<List<IdentityUser>> GetListAsync( |
|
|
|
string sorting = null, |
|
|
|
string sorting = null, |
|
|
|
int maxResultCount = int.MaxValue, |
|
|
|
int skipCount = 0, |
|
|
|
string filter = null, |
|
|
|
int skipCount = 0, |
|
|
|
string filter = null, |
|
|
|
bool includeDetails = false, |
|
|
|
CancellationToken cancellationToken = default) |
|
|
|
{ |
|
|
|
@ -142,9 +142,9 @@ namespace Volo.Abp.Identity.EntityFrameworkCore |
|
|
|
var query = from userRole in DbContext.Set<IdentityUserRole>() |
|
|
|
join role in DbContext.Roles.IncludeDetails(includeDetails) on userRole.RoleId equals role.Id |
|
|
|
where userRole.UserId == id |
|
|
|
select role; |
|
|
|
|
|
|
|
//TODO: Needs improvement
|
|
|
|
select role; |
|
|
|
|
|
|
|
//TODO: Needs improvement
|
|
|
|
var userOrganizationsQuery = from userOrg in DbContext.Set<IdentityUserOrganizationUnit>() |
|
|
|
join ou in DbContext.OrganizationUnits.IncludeDetails(includeDetails) on userOrg.OrganizationUnitId equals ou.Id |
|
|
|
where userOrg.UserId == id |
|
|
|
@ -156,13 +156,13 @@ namespace Volo.Abp.Identity.EntityFrameworkCore |
|
|
|
var orgRoles = DbContext.Roles.Where(q => orgUserRoleQuery.Contains(q.Id)); |
|
|
|
var resultQuery = query.Union(orgRoles); |
|
|
|
|
|
|
|
return await resultQuery.ToListAsync(GetCancellationToken(cancellationToken)); |
|
|
|
|
|
|
|
return await resultQuery.ToListAsync(GetCancellationToken(cancellationToken)); |
|
|
|
|
|
|
|
//return await query.ToListAsync(GetCancellationToken(cancellationToken));
|
|
|
|
} |
|
|
|
|
|
|
|
public virtual async Task<long> GetCountAsync( |
|
|
|
string filter = null, |
|
|
|
string filter = null, |
|
|
|
CancellationToken cancellationToken = default) |
|
|
|
{ |
|
|
|
return await this.WhereIf( |
|
|
|
|