Example #1
0
        // Data operation
        private IEnumerator CheckValidRoutine()
        {
            valid = false;
            if (Data.Validation.IsValidName(UsernameInput.text))
            {
                UsernameErrorText.text = " Verifying...";

                Data.Database.MySQL.Table output = new Data.Database.MySQL.Table();
                yield return(menuSystem.uiSystem.systemMediator.dataSystem.databaseSystem.query.Account.List(output, UsernameInput.text));

                if (output.success) // we need to check if sql was successful
                {
                    UsernameErrorText.text = (output.Length == 0) ? "OK" : "Unavailable";
                }
            }
            else
            {
                UsernameErrorText.text = "Invalid";
            }

            PasswordErrorText.text        = (PasswordInput.text == ConfirmPasswordInput.text) ? "OK" : "Passwords must match";
            ConfirmPasswordErrorText.text = PasswordErrorText.text;
            EmailErrorText.text           = (Data.Validation.IsValidEmail(EmailInput.text)) ? "OK" : "Invalid";
            if (UsernameErrorText.text == "OK" && PasswordErrorText.text == "OK" && ConfirmPasswordErrorText.text == "OK" && EmailErrorText.text == "OK")
            {
                valid = true;
            }
        }
Example #2
0
        private IEnumerator TryLoginRoutine()
        {
            if (Data.Validation.IsValidName(UsernameInput.text))
            {
                // Check if username exists
                UsernameErrorText.text = " Verifying...";

                Data.Database.MySQL.Table output = new Data.Database.MySQL.Table();
                yield return(menuSystem.uiSystem.systemMediator.dataSystem.databaseSystem.query.Account.List(output, UsernameInput.text));

                if (output.success && output.Length == 1)
                {
                    UsernameErrorText.text = "";

                    // Check login values against server
                    string encrypted_password = Data.Validation.Md5Sum(PasswordInput.text);

                    yield return(menuSystem.uiSystem.systemMediator.dataSystem.databaseSystem.query.Account.List(output, UsernameInput.text, encrypted_password));

                    if (output.success && output.Length == 1)
                    {
                        Login(output["name"][0]);
                    }
                    else
                    {
                        LoginButton.interactable = false;
                        PasswordErrorText.text   = "Incorrect password";
                        EventSystem.current.SetSelectedGameObject(PasswordInput.gameObject, new BaseEventData(EventSystem.current));
                    }
                }
                else
                {
                    LoginButton.interactable = false;
                    UsernameErrorText.text   = "No such username";
                    EventSystem.current.SetSelectedGameObject(UsernameInput.gameObject, new BaseEventData(EventSystem.current));
                }
            }
            else
            {
                UsernameErrorText.text = "Invalid";
            }
        }