Browse Source
Add GetUsersByPasskeyIdAsync method to identity user repositories
pull/24456/head
maliming
9 months ago
No known key found for this signature in database
GPG Key ID: A646B9CB645ECEA4
4 changed files with
54 additions and
0 deletions
-
modules/identity/src/Volo.Abp.Identity.Domain/Volo/Abp/Identity/IIdentityUserRepository.cs
-
modules/identity/src/Volo.Abp.Identity.Domain/Volo/Abp/Identity/IdentityUserManager.cs
-
modules/identity/src/Volo.Abp.Identity.EntityFrameworkCore/Volo/Abp/Identity/EntityFrameworkCore/EfCoreIdentityUserRepository.cs
-
modules/identity/src/Volo.Abp.Identity.MongoDB/Volo/Abp/Identity/MongoDB/MongoIdentityUserRepository.cs
|
|
@ -197,6 +197,12 @@ public interface IIdentityUserRepository : IBasicRepository<IdentityUser, Guid> |
|
|
CancellationToken cancellationToken = default |
|
|
CancellationToken cancellationToken = default |
|
|
); |
|
|
); |
|
|
|
|
|
|
|
|
|
|
|
Task<List<IdentityUser>> GetUsersByPasskeyIdAsync( |
|
|
|
|
|
[NotNull] byte[] credentialId, |
|
|
|
|
|
bool includeDetails = false, |
|
|
|
|
|
CancellationToken cancellationToken = default |
|
|
|
|
|
); |
|
|
|
|
|
|
|
|
Task<IdentityUser> FindByNormalizedUserNameAsync( |
|
|
Task<IdentityUser> FindByNormalizedUserNameAsync( |
|
|
Guid? tenantId, |
|
|
Guid? tenantId, |
|
|
[NotNull] string normalizedUserName, |
|
|
[NotNull] string normalizedUserName, |
|
|
|
|
|
@ -687,4 +687,35 @@ public class IdentityUserManager : UserManager<IdentityUser>, IDomainService |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public virtual async Task<IdentityUser> FindByPasskeyIdInHostAsync(byte[] credentialId) |
|
|
|
|
|
{ |
|
|
|
|
|
if (MultiTenancyOptions.Value.UserSharingStrategy == TenantUserSharingStrategy.Isolated) |
|
|
|
|
|
{ |
|
|
|
|
|
return await base.FindByPasskeyIdAsync(credentialId); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
using (CurrentTenant.Change(null)) |
|
|
|
|
|
{ |
|
|
|
|
|
using (DataFilter.Disable<IMultiTenant>()) |
|
|
|
|
|
{ |
|
|
|
|
|
var hostusers = await UserRepository.GetUsersByPasskeyIdAsync(credentialId, cancellationToken: CancellationToken); |
|
|
|
|
|
//host user first
|
|
|
|
|
|
var hostUser = hostusers.FirstOrDefault(x => x.TenantId == null) ?? hostusers.FirstOrDefault(); |
|
|
|
|
|
if (hostUser == null) |
|
|
|
|
|
{ |
|
|
|
|
|
return null; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
using (DataFilter.Enable<IMultiTenant>()) |
|
|
|
|
|
{ |
|
|
|
|
|
using (CurrentTenant.Change(hostUser.TenantId)) |
|
|
|
|
|
{ |
|
|
|
|
|
return await base.FindByPasskeyIdAsync(credentialId); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
@ -502,6 +502,15 @@ public class EfCoreIdentityUserRepository : EfCoreRepository<IIdentityDbContext, |
|
|
.ToListAsync(GetCancellationToken(cancellationToken)); |
|
|
.ToListAsync(GetCancellationToken(cancellationToken)); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public virtual async Task<List<IdentityUser>> GetUsersByPasskeyIdAsync(byte[] credentialId, bool includeDetails = false, CancellationToken cancellationToken = default) |
|
|
|
|
|
{ |
|
|
|
|
|
return await (await GetDbSetAsync()) |
|
|
|
|
|
.IncludeDetails(includeDetails) |
|
|
|
|
|
.Where(u => u.Passkeys.Any(x => x.CredentialId.SequenceEqual(credentialId))) |
|
|
|
|
|
.OrderBy(x => x.Id) |
|
|
|
|
|
.ToListAsync(GetCancellationToken(cancellationToken)); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
public virtual async Task<IdentityUser> FindByNormalizedUserNameAsync(Guid? tenantId, string normalizedUserName, bool includeDetails = true, CancellationToken cancellationToken = default) |
|
|
public virtual async Task<IdentityUser> FindByNormalizedUserNameAsync(Guid? tenantId, string normalizedUserName, bool includeDetails = true, CancellationToken cancellationToken = default) |
|
|
{ |
|
|
{ |
|
|
return await (await GetDbSetAsync()) |
|
|
return await (await GetDbSetAsync()) |
|
|
|
|
|
@ -493,6 +493,14 @@ public class MongoIdentityUserRepository : MongoDbRepository<IAbpIdentityMongoDb |
|
|
.ToListAsync(cancellationToken: cancellationToken); |
|
|
.ToListAsync(cancellationToken: cancellationToken); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public virtual async Task<List<IdentityUser>> GetUsersByPasskeyIdAsync(byte[] credentialId, bool includeDetails = false, CancellationToken cancellationToken = default) |
|
|
|
|
|
{ |
|
|
|
|
|
return await (await GetQueryableAsync(cancellationToken)) |
|
|
|
|
|
.OrderBy(x => x.Id) |
|
|
|
|
|
.Where(u => u.Passkeys.Any(x => x.CredentialId == credentialId)) |
|
|
|
|
|
.ToListAsync(cancellationToken: cancellationToken); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
public virtual async Task<IdentityUser> FindByNormalizedUserNameAsync(Guid? tenantId, string normalizedUserName, bool includeDetails = true, CancellationToken cancellationToken = default) |
|
|
public virtual async Task<IdentityUser> FindByNormalizedUserNameAsync(Guid? tenantId, string normalizedUserName, bool includeDetails = true, CancellationToken cancellationToken = default) |
|
|
{ |
|
|
{ |
|
|
return await (await GetQueryableAsync(cancellationToken)) |
|
|
return await (await GetQueryableAsync(cancellationToken)) |
|
|
|