Fix refresh login menu & login menu error messages

This commit is contained in:
2025-06-15 15:44:46 -07:00
parent 3ce13f5b1f
commit c5e51b53dd
2 changed files with 64 additions and 86 deletions

View File

@@ -43,59 +43,52 @@ public class AccountLogin : MonoBehaviour
return; return;
} }
string response = SensitiveInfo.Decrypt(request.downloadHandler.text, SensitiveInfo.SERVER_RECEIVE_TRANSFER_KEY); string response = SensitiveInfo.Decrypt(request.downloadHandler.text, SensitiveInfo.SERVER_RECEIVE_TRANSFER_KEY);
if (response != "-1") if (response == "-999")
{ {
if (response == "-999") AccountHandler.UpdateStatusText(loginPanelStatusText, "Server error while fetching data", Color.red);
{ return;
AccountHandler.UpdateStatusText(loginPanelStatusText, "Server error while fetching data", Color.red); }
return; else if (response == "-998")
} {
else if (response == "-998") AccountHandler.UpdateStatusText(loginPanelStatusText, "Client version too outdated to access servers", Color.red);
{ return;
AccountHandler.UpdateStatusText(loginPanelStatusText, "Client version too outdated to access servers", Color.red); }
return; else if (response == "-997")
} {
else if (response == "-997") AccountHandler.UpdateStatusText(loginPanelStatusText, "Encryption/decryption issues", Color.red);
{ return;
AccountHandler.UpdateStatusText(loginPanelStatusText, "Encryption/decryption issues", Color.red); }
return; else if (response == "-1")
} {
else if (response == "-2") AccountHandler.UpdateStatusText(loginPanelStatusText, "Incorrect username or password", Color.red);
{ }
AccountHandler.UpdateStatusText(loginPanelStatusText, "Incorrect username or password", Color.red); else if (response.Split(":")[0] == "1")
} {
else if (response.Split(":")[0] == "1") string[] array = response.Split(':');
{ string session = array[1];
string[] array = response.Split(':'); string userName = array[2];
string session = array[1]; int userId = int.Parse(array[3]);
string userName = array[2]; BigInteger highScore = BigInteger.Parse(array[4]);
int userId = int.Parse(array[3]); int iconId = int.Parse(array[5]);
BigInteger highScore = BigInteger.Parse(array[4]); int overlayId = int.Parse(array[6]);
int iconId = int.Parse(array[5]); PlayerPrefs.SetString("gameSession", session);
int overlayId = int.Parse(array[6]); PlayerPrefs.SetString("userName", userName);
PlayerPrefs.SetString("gameSession", session); PlayerPrefs.SetInt("userId", userId);
PlayerPrefs.SetString("userName", userName); PlayerPrefs.SetString("HighScoreV2", highScore.ToString());
PlayerPrefs.SetInt("userId", userId); PlayerPrefs.SetInt("icon", iconId);
PlayerPrefs.SetString("HighScoreV2", highScore.ToString()); PlayerPrefs.SetInt("overlay", overlayId);
PlayerPrefs.SetInt("icon", iconId); PlayerPrefs.SetString("TotalNormalBerries", array[7]);
PlayerPrefs.SetInt("overlay", overlayId); PlayerPrefs.SetString("TotalPoisonBerries", array[8]);
PlayerPrefs.SetString("TotalNormalBerries", array[7]); PlayerPrefs.SetString("TotalSlowBerries", array[9]);
PlayerPrefs.SetString("TotalPoisonBerries", array[8]); PlayerPrefs.SetString("TotalUltraBerries", array[10]);
PlayerPrefs.SetString("TotalSlowBerries", array[9]); PlayerPrefs.SetString("TotalSpeedyBerries", array[11]);
PlayerPrefs.SetString("TotalUltraBerries", array[10]); PlayerPrefs.SetString("TotalAttempts", array[12]);
PlayerPrefs.SetString("TotalSpeedyBerries", array[11]); AccountHandler.instance.SwitchPanel(0);
PlayerPrefs.SetString("TotalAttempts", array[12]); AccountHandler.UpdateStatusText(loginPanelStatusText, "", Color.red);
AccountHandler.instance.SwitchPanel(0);
AccountHandler.UpdateStatusText(loginPanelStatusText, "", Color.red);
}
else
{
AccountHandler.UpdateStatusText(loginPanelStatusText, "Unknown server response", Color.red);
}
} }
else else
{ {
AccountHandler.UpdateStatusText(loginPanelStatusText, "Internal login server error", Color.red); AccountHandler.UpdateStatusText(loginPanelStatusText, "Unknown server response", Color.red);
} }
} }
} }

View File

@@ -40,47 +40,32 @@ public class AccountRefreshLogin : MonoBehaviour
return; return;
} }
string response = SensitiveInfo.Decrypt(request.downloadHandler.text, SensitiveInfo.SERVER_RECEIVE_TRANSFER_KEY); string response = SensitiveInfo.Decrypt(request.downloadHandler.text, SensitiveInfo.SERVER_RECEIVE_TRANSFER_KEY);
if (response != "-1") if (response == "-999")
{ {
if (response == "-999") AccountHandler.UpdateStatusText(refreshLoginStatusText, "Server error while fetching data", Color.red);
{ return;
AccountHandler.UpdateStatusText(refreshLoginStatusText, "Server error while fetching data", Color.red); }
return; else if (response == "-998")
} {
else if (response == "-998") AccountHandler.UpdateStatusText(refreshLoginStatusText, "Client version too outdated to access servers", Color.red);
{ return;
AccountHandler.UpdateStatusText(refreshLoginStatusText, "Client version too outdated to access servers", Color.red); }
return; else if (response == "-997")
} {
else if (response == "-997") AccountHandler.UpdateStatusText(refreshLoginStatusText, "Encryption/decryption issues", Color.red);
{ return;
AccountHandler.UpdateStatusText(refreshLoginStatusText, "Encryption/decryption issues", Color.red); }
return; else if (response == "-1")
} {
else if (response == "-2") AccountHandler.UpdateStatusText(refreshLoginStatusText, "Incorrect username or password", Color.red);
{ }
AccountHandler.UpdateStatusText(refreshLoginStatusText, "Incorrect username or password", Color.red); else if (response == "1")
} {
else if (response.Split(":")[0] == "1") AccountHandler.instance.SwitchPanel(0);
{
string[] array = response.Split(':');
string session = array[1];
string userName = array[2];
int userId = int.Parse(array[3]);
PlayerPrefs.SetString("gameSession", session);
PlayerPrefs.SetString("userName", userName);
PlayerPrefs.SetInt("userId", userId);
AccountHandler.instance.SwitchPanel(0);
AccountHandler.UpdateStatusText(refreshLoginStatusText, "", Color.red);
}
else
{
AccountHandler.UpdateStatusText(refreshLoginStatusText, "Unknown server response", Color.red);
}
} }
else else
{ {
AccountHandler.UpdateStatusText(refreshLoginStatusText, "Internal login server error", Color.red); AccountHandler.UpdateStatusText(refreshLoginStatusText, "Unknown server response", Color.red);
} }
} }
} }