Fix name check not working correctly

This commit is contained in:
Amelia 2025-07-01 13:17:38 +02:00
parent 5104a66cae
commit e8f74709f3
No known key found for this signature in database
GPG key ID: D6D0ECE365407EAA

View file

@ -107,7 +107,7 @@ public class OidcService(ILogger<OidcService> logger, UserManager<AppUser> userM
name ??= claimsPrincipal.FindFirstValue(ClaimTypes.Surname); name ??= claimsPrincipal.FindFirstValue(ClaimTypes.Surname);
name ??= emailClaim.Value; name ??= emailClaim.Value;
var other = await unitOfWork.UserRepository.GetUserByUsernameAsync(name); var other = await userManager.FindByNameAsync(name);
if (other != null) if (other != null)
{ {
// We match by email, so this will always be unique // We match by email, so this will always be unique
@ -122,7 +122,7 @@ public class OidcService(ILogger<OidcService> logger, UserManager<AppUser> userM
if (!res.Succeeded) if (!res.Succeeded)
{ {
logger.LogError("Failed to create new user from OIDC: {Errors}", logger.LogError("Failed to create new user from OIDC: {Errors}",
res.Errors.Select(x => x.Description).ToString()); res.Errors.Select(x => x.Description).ToList());
throw new KavitaException("errors.oidc.creating-user"); throw new KavitaException("errors.oidc.creating-user");
} }