Handle Redump 503s / Timeouts (fixes #289)

This commit is contained in:
Matt Nadareski
2021-06-20 11:21:43 -07:00
parent 27ca4fd1af
commit 347beca874
2 changed files with 10 additions and 4 deletions

View File

@@ -299,6 +299,7 @@ namespace MPF.Redump
if (request is HttpWebRequest webRequest)
{
webRequest.CookieContainer = m_container;
webRequest.Timeout = 5 * 1000;
}
return request;
@@ -346,11 +347,16 @@ namespace MPF.Redump
Encoding = Encoding.UTF8;
var response = UploadString(loginUrl, $"form_sent=1&redirect_url=&csrf_token={token}&req_username={username}&req_password={password}&save_pass=0&login=Login");
if (response.Contains("Incorrect username and/or password."))
if (response.Contains("Incorrect username and/or password"))
{
Console.WriteLine("Invalid credentials entered, continuing without logging in...");
return false;
}
else if (response.Contains("503 Service Unavailable"))
{
Console.WriteLine("Redump is not currently responding, continuing without logging in...");
return null;
}
// The user was able to be logged in
Console.WriteLine("Credentials accepted! Logged into Redump...");

View File

@@ -210,11 +210,11 @@ namespace MPF.Windows
{
bool? loggedIn = wc.Login(RedumpUsernameTextBox.Text, RedumpPasswordBox.Password);
if (loggedIn == true)
CustomMessageBox.Show("Redump login credentials accepted!", "Success", MessageBoxButton.OK, MessageBoxImage.Information);
CustomMessageBox.Show(this, "Redump login credentials accepted!", "Success", MessageBoxButton.OK, MessageBoxImage.Information);
else if (loggedIn == false)
CustomMessageBox.Show("Redump login credentials denied!", "Failure", MessageBoxButton.OK, MessageBoxImage.Error);
CustomMessageBox.Show(this, "Redump login credentials denied!", "Failure", MessageBoxButton.OK, MessageBoxImage.Error);
else
CustomMessageBox.Show("Error validating credentials!", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
CustomMessageBox.Show(this, "Error validating credentials!", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
}
}