Update account change username script for server rewrite

This commit is contained in:
2025-07-12 15:42:55 -07:00
parent 6003ea3fb3
commit 37f11aa7ae
2 changed files with 30 additions and 29 deletions

View File

@@ -50,7 +50,6 @@ public class AccountChangePassword : MonoBehaviour
return;
}
string response = SensitiveInfo.Decrypt(request.downloadHandler.text, SensitiveInfo.SERVER_RECEIVE_TRANSFER_KEY);
if (response == "-999")
{
AccountHandler.UpdateStatusText(changePasswordStatusText, "Server error while fetching data", Color.red);

View File

@@ -1,3 +1,4 @@
using Newtonsoft.Json.Linq;
using TMPro;
using UnityEngine;
using UnityEngine.Networking;
@@ -42,38 +43,39 @@ public class AccountChangeUsername : MonoBehaviour
return;
}
string response = SensitiveInfo.Decrypt(request.downloadHandler.text, SensitiveInfo.SERVER_RECEIVE_TRANSFER_KEY);
switch (response)
if (response == "-999")
{
case "-999":
AccountHandler.UpdateStatusText(changeUsernameStatusText, "Server error while fetching data", Color.red);
break;
case "-998":
return;
}
else if (response == "-998")
{
AccountHandler.UpdateStatusText(changeUsernameStatusText, "Client version too outdated to access servers", Color.red);
break;
case "-997":
return;
}
else if (response == "-997")
{
AccountHandler.UpdateStatusText(changeUsernameStatusText, "Encryption/decryption issues", Color.red);
break;
case "-996":
return;
}
else if (response == "-996")
{
AccountHandler.UpdateStatusText(changeUsernameStatusText, "Can't send requests on self-built instance", Color.red);
break;
case "1":
return;
}
else
{
var jsonResponse = JObject.Parse(response);
if ((bool)jsonResponse["success"])
{
BazookaManager.Instance.SetAccountName(changeUsernameNewUsernameInput.text);
AccountHandler.instance.SwitchPanel(0);
AccountHandler.UpdateStatusText(AccountHandler.instance.accountLoggedIn.loggedInText, "Username changed successfully", Color.green);
break;
case "-1":
AccountHandler.UpdateStatusText(changeUsernameStatusText, "New Username must be 3-16 characters, letters and numbers only", Color.red);
break;
case "-2":
AccountHandler.UpdateStatusText(changeUsernameStatusText, "New username already exists", Color.red);
break;
case "-3":
AccountHandler.instance.SwitchPanel(0);
AccountHandler.UpdateStatusText(AccountHandler.instance.accountLoggedIn.loggedInText, "Failed to find info about your user (refresh login?)", Color.red);
break;
default:
AccountHandler.UpdateStatusText(changeUsernameStatusText, "Unknown server response", Color.red);
break;
}
else
{
AccountHandler.UpdateStatusText(changeUsernameStatusText, (string)jsonResponse["message"], Color.red);
}
}
}
}