Browse Source

Improve host user selection logic in IdentityUserManager

pull/24456/head
maliming 6 months ago
parent
commit
dbe0dbc3bb
No known key found for this signature in database GPG Key ID: A646B9CB645ECEA4
  1. 8
      modules/identity/src/Volo.Abp.Identity.Domain/Volo/Abp/Identity/IdentityUserManager.cs

8
modules/identity/src/Volo.Abp.Identity.Domain/Volo/Abp/Identity/IdentityUserManager.cs

@ -610,7 +610,7 @@ public class IdentityUserManager : UserManager<IdentityUser>, IDomainService
var normalizedEmail = NormalizeEmail(email);
var hostusers = await UserRepository.GetUsersByNormalizedEmailAsync(normalizedEmail, cancellationToken: CancellationToken);
//host user first
var hostUser = hostusers.FirstOrDefault(x => x.TenantId == null) ?? hostusers.FirstOrDefault();
var hostUser = hostusers.FirstOrDefault(x => x.TenantId == null) ?? hostusers.FirstOrDefault(x => x.TenantId != Guid.Empty) ?? hostusers.FirstOrDefault();
if (hostUser == null)
{
return null;
@ -641,7 +641,7 @@ public class IdentityUserManager : UserManager<IdentityUser>, IDomainService
var normalizeduserName = NormalizeName(userName);
var hostusers = await UserRepository.GetUsersByNormalizedUserNameAsync(normalizeduserName, cancellationToken: CancellationToken);
//host user first
var hostUser = hostusers.FirstOrDefault(x => x.TenantId == null) ?? hostusers.FirstOrDefault();
var hostUser = hostusers.FirstOrDefault(x => x.TenantId == null) ?? hostusers.FirstOrDefault(x => x.TenantId != Guid.Empty) ?? hostusers.FirstOrDefault();
if (hostUser == null)
{
return null;
@ -671,7 +671,7 @@ public class IdentityUserManager : UserManager<IdentityUser>, IDomainService
{
var hostusers = await UserRepository.GetUsersByLoginAsync(loginProvider, providerKey, cancellationToken: CancellationToken);
//host user first
var hostUser = hostusers.FirstOrDefault(x => x.TenantId == null) ?? hostusers.FirstOrDefault();
var hostUser = hostusers.FirstOrDefault(x => x.TenantId == null) ?? hostusers.FirstOrDefault(x => x.TenantId != Guid.Empty) ?? hostusers.FirstOrDefault();
if (hostUser == null)
{
return null;
@ -701,7 +701,7 @@ public class IdentityUserManager : UserManager<IdentityUser>, IDomainService
{
var hostusers = await UserRepository.GetUsersByPasskeyIdAsync(credentialId, cancellationToken: CancellationToken);
//host user first
var hostUser = hostusers.FirstOrDefault(x => x.TenantId == null) ?? hostusers.FirstOrDefault();
var hostUser = hostusers.FirstOrDefault(x => x.TenantId == null) ?? hostusers.FirstOrDefault(x => x.TenantId != Guid.Empty) ?? hostusers.FirstOrDefault();
if (hostUser == null)
{
return null;

Loading…
Cancel
Save