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
|
Password = password
|
||||||
}));
|
}));
|
||||||
|
|
||||||
if (String.IsNullOrWhiteSpace(response.Data.AccessToken))
|
|
||||||
throw new WebException("Invalid username or password");
|
|
||||||
|
|
||||||
switch (response.StatusCode)
|
switch (response.StatusCode)
|
||||||
{
|
{
|
||||||
case HttpStatusCode.OK:
|
case HttpStatusCode.OK:
|
||||||
|
@ -80,6 +77,7 @@ namespace LANCommander.PlaynitePlugin
|
||||||
|
|
||||||
case HttpStatusCode.Forbidden:
|
case HttpStatusCode.Forbidden:
|
||||||
case HttpStatusCode.BadRequest:
|
case HttpStatusCode.BadRequest:
|
||||||
|
case HttpStatusCode.Unauthorized:
|
||||||
throw new WebException("Invalid username or password");
|
throw new WebException("Invalid username or password");
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
|
|
@ -113,6 +113,12 @@ namespace LANCommander.PlaynitePlugin.Views
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
Plugin.PlayniteApi.Dialogs.ShowErrorMessage(ex.Message);
|
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")]
|
[HttpPost("Validate")]
|
||||||
|
|
Loading…
Add table
Reference in a new issue