public static bool login(User user)
        {
            bool closeWin = false;
            var response = Communication.postData(Api.EndpointRefs.loginURL, user);
            JToken j = JToken.Parse(response.Item2);

            switch(response.Item1){
                case 200:
                    closeWin = processToken(j);
                    ComputerAdder.addComputer();
                    break;
                case 302:
                case 401:
                case 404:
                    MessageBox.Show((string)j["data"]);
                    break;
                case 400:
                    MessageBox.Show((string) j["data"]["error"]);
                    break;
                default:
                    MessageBox.Show("Failed logging In");
                    break;
            }

            return closeWin;
        }
        public static bool register(User user)
        {
            bool closeWin = false;
            var response = Communication.postData(Api.EndpointRefs.registerURL, user);
            JToken j = JToken.Parse(response.Item2);

            switch (response.Item1)
            {
                case 201:
                    MessageBox.Show((string)j["data"]["username"] + " has been registered. Please login now.");
                    closeWin = true;
                    break;
                case 302:
                    MessageBox.Show("User by that name already exists.");
                    break;
                case 400:
                    MessageBox.Show((string)j["data"]["error"]);
                    break;
                default:
                    MessageBox.Show("Failed to register user.");
                    break;
            }

            return closeWin;
        }
        private void btn_Login_Click(object sender, EventArgs e)
        {
            bool login = false;
            string passHash = Tools.HashingTools.sha256Hash(txt_Password.Text);
            User user = new User(txt_Username.Text, passHash);
            if (Tools.UserTools.checkUsernameLength(user.username)) login = Api.Endpoints.UserAuth.login(user);
            else MessageBox.Show("Username must be between 4 and 16 characters long");

            if(login) this.Close();
        }
        private void btn_Submit_Click(object sender, EventArgs e)
        {
            bool reg = false;
            string passHash = Tools.HashingTools.sha256Hash(txt_Password.Text);
            User user = new User(txt_Username.Text, passHash, txt_Email.Text);

            if (Tools.UserTools.checkUsernameLength(user.username))
            {
                if (Tools.UserTools.checkEmailLength(user.email))
                {
                    reg = Api.Endpoints.UserAuth.register(user);
                }
                else MessageBox.Show("Email must be between 7 and 30 characters long");
            }
            else MessageBox.Show("Username must be between 4 and 16 characters long");

            if (reg) this.Close();
        }