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; 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 == "-999") if (response == "-999")
{ {
AccountHandler.UpdateStatusText(changePasswordStatusText, "Server error while fetching data", Color.red); AccountHandler.UpdateStatusText(changePasswordStatusText, "Server error while fetching data", Color.red);

View File

@@ -1,3 +1,4 @@
using Newtonsoft.Json.Linq;
using TMPro; using TMPro;
using UnityEngine; using UnityEngine;
using UnityEngine.Networking; using UnityEngine.Networking;
@@ -42,38 +43,39 @@ public class AccountChangeUsername : 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);
switch (response) if (response == "-999")
{ {
case "-999":
AccountHandler.UpdateStatusText(changeUsernameStatusText, "Server error while fetching data", Color.red); AccountHandler.UpdateStatusText(changeUsernameStatusText, "Server error while fetching data", Color.red);
break; return;
case "-998": }
else if (response == "-998")
{
AccountHandler.UpdateStatusText(changeUsernameStatusText, "Client version too outdated to access servers", Color.red); AccountHandler.UpdateStatusText(changeUsernameStatusText, "Client version too outdated to access servers", Color.red);
break; return;
case "-997": }
else if (response == "-997")
{
AccountHandler.UpdateStatusText(changeUsernameStatusText, "Encryption/decryption issues", Color.red); AccountHandler.UpdateStatusText(changeUsernameStatusText, "Encryption/decryption issues", Color.red);
break; return;
case "-996": }
else if (response == "-996")
{
AccountHandler.UpdateStatusText(changeUsernameStatusText, "Can't send requests on self-built instance", Color.red); AccountHandler.UpdateStatusText(changeUsernameStatusText, "Can't send requests on self-built instance", Color.red);
break; return;
case "1": }
else
{
var jsonResponse = JObject.Parse(response);
if ((bool)jsonResponse["success"])
{
BazookaManager.Instance.SetAccountName(changeUsernameNewUsernameInput.text); BazookaManager.Instance.SetAccountName(changeUsernameNewUsernameInput.text);
AccountHandler.instance.SwitchPanel(0); AccountHandler.instance.SwitchPanel(0);
AccountHandler.UpdateStatusText(AccountHandler.instance.accountLoggedIn.loggedInText, "Username changed successfully", Color.green); AccountHandler.UpdateStatusText(AccountHandler.instance.accountLoggedIn.loggedInText, "Username changed successfully", Color.green);
break; }
case "-1": else
AccountHandler.UpdateStatusText(changeUsernameStatusText, "New Username must be 3-16 characters, letters and numbers only", Color.red); {
break; AccountHandler.UpdateStatusText(changeUsernameStatusText, (string)jsonResponse["message"], Color.red);
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;
} }
} }
} }