Handle invalid logins properly

This commit is contained in:
Pat Hartl 2023-03-14 01:10:02 -05:00
parent 4277b50198
commit 43f0e3823d
3 changed files with 8 additions and 4 deletions

View file

@ -70,9 +70,6 @@ namespace LANCommander.PlaynitePlugin
Password = password
}));
if (String.IsNullOrWhiteSpace(response.Data.AccessToken))
throw new WebException("Invalid username or password");
switch (response.StatusCode)
{
case HttpStatusCode.OK:
@ -80,6 +77,7 @@ namespace LANCommander.PlaynitePlugin
case HttpStatusCode.Forbidden:
case HttpStatusCode.BadRequest:
case HttpStatusCode.Unauthorized:
throw new WebException("Invalid username or password");
default:

View file

@ -113,6 +113,12 @@ namespace LANCommander.PlaynitePlugin.Views
catch (Exception ex)
{
Plugin.PlayniteApi.Dialogs.ShowErrorMessage(ex.Message);
LoginButton.Dispatcher.Invoke(new System.Action(() =>
{
LoginButton.IsEnabled = true;
LoginButton.Content = "Login";
}));
}
}
}

View file

@ -75,7 +75,7 @@ namespace LANCommander.Controllers.Api
});
}
return RedirectToAction("Index", "Home");
return Unauthorized();
}
[HttpPost("Validate")]