mirror of
https://github.com/LD-Reborn/Berufsschule_HAM.git
synced 2025-12-20 06:51:55 +00:00
Fixed uncaught exception when user not found
This commit is contained in:
@@ -144,16 +144,23 @@ public partial class LdapService : IDisposable
|
||||
await ConnectAndBind();
|
||||
try
|
||||
{
|
||||
UserModel user = await GetUserByUidAsync(username);
|
||||
if (user.UserPassword is null)
|
||||
try
|
||||
{
|
||||
UserModel user = await GetUserByUidAsync(username);
|
||||
if (user.UserPassword is null)
|
||||
{
|
||||
return new() { Success = false, AuthenticationState = UserNotAuthenticatedReason.InvalidCredentials };
|
||||
}
|
||||
if (CompareStringToSha256(password, user.UserPassword))
|
||||
{
|
||||
return new() { Success = true };
|
||||
}
|
||||
return new() { Success = false, AuthenticationState = UserNotAuthenticatedReason.InvalidCredentials };
|
||||
}
|
||||
catch (InvalidOperationException)
|
||||
{
|
||||
return new() { Success = false, AuthenticationState = UserNotAuthenticatedReason.InvalidCredentials };
|
||||
}
|
||||
if (CompareStringToSha256(password, user.UserPassword))
|
||||
{
|
||||
return new() { Success = true};
|
||||
}
|
||||
return new() { Success = false, AuthenticationState = UserNotAuthenticatedReason.InvalidCredentials };
|
||||
}
|
||||
catch (LdapException)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user