Handle invalid logins properly
This commit is contained in:
parent
4277b50198
commit
43f0e3823d
3 changed files with 8 additions and 4 deletions
|
@ -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:
|
||||
|
|
|
@ -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";
|
||||
}));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -75,7 +75,7 @@ namespace LANCommander.Controllers.Api
|
|||
});
|
||||
}
|
||||
|
||||
return RedirectToAction("Index", "Home");
|
||||
return Unauthorized();
|
||||
}
|
||||
|
||||
[HttpPost("Validate")]
|
||||
|
|
Loading…
Add table
Reference in a new issue