diff --git a/Assets/MYSQL.txt b/Assets/MYSQL.txt index f70eb1d..bd302be 100644 --- a/Assets/MYSQL.txt +++ b/Assets/MYSQL.txt @@ -27,4 +27,10 @@ CREATE TABLE pwdreset ( pwd_selector TEXT NOT NULL, #Where the selector is stored in plaintext pwd_token LONGTEXT NOT NULL, #Where the hashed token is stored pwd_expires TEXT NOT NULL #When the token expires +); + +CREATE TABLE money_spent( + user_id int(11) PRIMARY KEY NOT NULL, + user_spent int(11) NOT NULL, + FOREIGN KEY (user_id) REFERENCES users(user_id) ); \ No newline at end of file diff --git a/Assets/Scripts/login/Login.cs b/Assets/Scripts/login/Login.cs index aa1f0bb..3634a1e 100644 --- a/Assets/Scripts/login/Login.cs +++ b/Assets/Scripts/login/Login.cs @@ -9,6 +9,7 @@ using Newtonsoft.Json; class LoginInformation { + public int id; public string user; public bool success; public string errors; @@ -24,12 +25,13 @@ public class Login : MonoBehaviour private bool CheckIsEmpty() //This checks if the strings are empty. { var strings = new List {username.text, password.text}; //This puts all of the text boxes into an array. - string check = "​"; //This is used for the check, the ZWSP is TMP's way of identifying nothing as null. + string check = ""; //​This is used for the check, the ZWSP is TMP's way of identifying nothing as null. if (strings.Contains(check)) //If any of the inputs are null. { + //Debug.Log("yes"); return true; } - + //Debug.Log("false"); return false; } @@ -84,16 +86,15 @@ public class Login : MonoBehaviour { string status = www.downloadHandler.text; //This downloads the data from the server. LoginInformation information = JsonConvert.DeserializeObject(status); //This deserializes the JSON string to a class. - + Debug.Log(status); if (information.success) //If the user has successfully logged in. { + UserManager.userID = information.id; UserManager.username = information.user; //This sets the logged in username. UnityEngine.SceneManagement.SceneManager.LoadScene(1); //Loads the menu scene. } - - InteractableForm(true); // This enables the form again. } - + InteractableForm(true); // This enables the form again. } } diff --git a/Assets/Scripts/login/UserManager.cs b/Assets/Scripts/login/UserManager.cs index d7e7aa3..50376d3 100644 --- a/Assets/Scripts/login/UserManager.cs +++ b/Assets/Scripts/login/UserManager.cs @@ -4,6 +4,7 @@ using UnityEngine; public static class UserManager { + public static int userID; public static string username; public static bool LoggedIn => username != null; diff --git a/Assets/Scripts/menu/MainMenu.cs b/Assets/Scripts/menu/MainMenu.cs index 650dda0..d5d275d 100644 --- a/Assets/Scripts/menu/MainMenu.cs +++ b/Assets/Scripts/menu/MainMenu.cs @@ -14,6 +14,7 @@ public class MainMenu : MonoBehaviour private string existingCards; void Start() { + Debug.Log("User ID: " + UserManager.userID); Debug.Log("Username: " + UserManager.username); if (!PropertiesHandler.CheckPropertyExists()) //Checks if the properties file doesn't exist. {