Fixed uncaught exception when user not found

This commit is contained in:
2025-10-03 16:40:16 +02:00
parent 0bb5f650b6
commit a5a08e5876

View File

@@ -142,6 +142,8 @@ public partial class LdapService : IDisposable
public async Task<UserAuthenticationResult> AuthenticateUser(string username, string password)
{
await ConnectAndBind();
try
{
try
{
UserModel user = await GetUserByUidAsync(username);
@@ -155,6 +157,11 @@ public partial class LdapService : IDisposable
}
return new() { Success = false, AuthenticationState = UserNotAuthenticatedReason.InvalidCredentials };
}
catch (InvalidOperationException)
{
return new() { Success = false, AuthenticationState = UserNotAuthenticatedReason.InvalidCredentials };
}
}
catch (LdapException)
{
return new() { Success = false, AuthenticationState = UserNotAuthenticatedReason.InvalidCredentials };