Beispiel #1
0
 private void ChangeEmailState()
 {
     inputValue = true;
     if (string.IsNullOrEmpty(EmailInput.text))
     {
         emailValidated = false;
         EmailOkay.SetActive(false);
         ShowErrorText(TacoConfig.TacoRegisteredErrorMessage06);
     }
     else
     {
         var  textEmail = EmailInput.text;
         bool isEmail   = TacoManager.ValidateEmail(textEmail);
         if (isEmail == true)
         {
             emailValidated = true;
             ShowErrorText();
             ChangeInputState();
             EmailOkay.SetActive(true);
         }
         else
         {
             emailValidated = false;
             ShowErrorText(TacoConfig.TacoRegisteredErrorMessage01);
             EmailOkay.SetActive(false);
         }
     }
     ToggleRegisterButton(AllInputIsValid());
 }
Beispiel #2
0
        private void AddRedeemFormValidation()
        {
            dateOfBirthInput.onEndEdit.AddListener((string value) => {
                ValidateRedeemAge(value);
            });

            RedeemSubmit.onClick.AddListener(() => {
                if (!TacoManager.ValidateEmail(emailInput.text))
                {
                    ToggleRedeemErrorMsg(TacoConfig.RedeemErrorIncorrectEmail);
                }
                else if (string.IsNullOrEmpty(dateOfBirthInput.text) || string.IsNullOrEmpty(streetInput.text) || string.IsNullOrEmpty(buildingInput.text) || string.IsNullOrEmpty(countryInput.text) ||
                         string.IsNullOrEmpty(stateInput.text) || string.IsNullOrEmpty(postcodeInput.text) || string.IsNullOrEmpty(cityInput.text))
                {
                    ToggleRedeemErrorMsg(TacoConfig.RedeemErrorNoFill);
                }
                else if (!isValidAge)
                {
                    ValidateRedeemAge(dateOfBirthInput.text);
                }
                else
                {
                    ToggleRedeemErrorMsg();
                    SubmitRedeemForm();
                }
            });
        }
Beispiel #3
0
        private bool validateInput()
        {
            var  email     = EmailInput.text;
            var  password  = PasswordInput.text;
            var  confirm   = ConfirmInput.text;
            var  age       = PolicyToggle.isOn;
            var  user      = UserInput.text;
            bool validated = true;

            if (string.IsNullOrEmpty(user))
            {
                validated = false;
                ShowErrorText(TacoConfig.TacoRegisteredErrorMessage03);
                return(validated);
            }

            if (string.IsNullOrEmpty(email))
            {
                validated = false;
                ShowErrorText(TacoConfig.TacoRegisteredErrorMessage06);
                return(validated);
            }
            else
            {
                bool isEmail = TacoManager.ValidateEmail(email);

                if (!isEmail)
                {
                    validated = false;
                    ShowErrorText(TacoConfig.TacoRegisteredErrorMessage01);
                    return(validated);
                }
            }

            if (string.IsNullOrEmpty(password) || string.IsNullOrEmpty(confirm))
            {
                validated = false;
                ShowErrorText(TacoConfig.TacoRegisteredErrorMessage04);
                return(validated);
            }
            // if (string.IsNullOrEmpty(user)) {
            //  validated = false;
            //  StatusText.text = TacoConfig.TacoRegisteredErrorMessage03;
            // }

            if (!string.IsNullOrEmpty(password) && !string.IsNullOrEmpty(confirm))
            {
                ShowErrorText(TacoConfig.TacoRegisteredErrorMessage04);

                if (password == confirm)
                {
                    if (password.Length <= 3)
                    {
                        validated = false;
                        ShowErrorText(TacoConfig.TacoRegisteredErrorMessage07);
                        return(validated);
                    }
                }
                else
                {
                    validated = false;
                    ShowErrorText(TacoConfig.TacoRegisteredErrorMessage00);
                    return(validated);
                }
            }
            else if (!ConfirmInput.isFocused)
            {
                validated = false;
                ShowErrorText(TacoConfig.TacoRegisteredErrorMessage04);
                return(validated);
            }

            if (!age)
            {
                validated = false;
                ShowErrorText(TacoConfig.TacoRegisteredErrorMessage02);
                ToggleRegisterButton(false);
                return(validated);
            }
            return(validated);
        }
Beispiel #4
0
        public void ValidateUserOrEmail(string emailToCheck)
        {
            if (string.IsNullOrEmpty(emailToCheck))
            {
                if (next != null && string.IsNullOrEmpty(next.EmailInput.text) && next.IsInteractable())
                {
                    next.SetInteractable(false);
                }
                return;
            }

            if (next != null && !next.IsInteractable())
            {
                next.SetInteractable(true);
            }

            if (!TacoManager.ValidateEmail(emailToCheck))
            {
                ToggleEmailOkay(false);
                RemoveDuplidateError();
                errorMessage.text = TacoConfig.EnterInvalidEmailError;
                return;
            }

            if (reservedEmails.Contains(GetEmail()))
            {
                ToggleEmailOkay(false);
                RemoveDuplidateError();
                errorMessage.text = TacoConfig.EnterExistingEmailError;
                return;
            }

            Action <string> success = (string data) => {
                GameFeaturedResult r = JsonUtility.FromJson <GameFeaturedResult>(data);

                if (r.success)
                {
                    if (data.Contains("true"))
                    {
                        if (!ValidateDuplidateEmail(emailToCheck))
                        {
                            ToggleEmailOkay(false);
                            errorMessage.text = TacoConfig.EnterExistingEmailError;
                        }
                        else
                        {
                            ToggleEmailOkay(true);
                        }
                        RemoveDuplidateError();
                        previousValidEmailValue = emailToCheck;
                    }
                }
                else
                {
                    ToggleEmailOkay(false);
                    RemoveDuplidateError();

                    errorMessage.text = TacoConfig.NotInSystemEmailError;
                }
            };

            Action <string, string> fail = (string errorData, string error) => {
                Debug.Log("Error on get : " + errorData);
                if (!string.IsNullOrEmpty(error))
                {
                    Debug.Log("Error : " + error);
                }
                TacoManager.CloseMessage();
                //string msg = errorData + (string.IsNullOrEmpty (error) ? "" : " : " + error);
                TacoManager.OpenModalLoginFailedPanel(TacoConfig.TacoLoginErrorEmailPassword);
                //TacoManager.OpenModal (TacoConfig.TacoLoginErrorHeader, TacoConfig.TacoLoginErrorMessage01);
            };


            string url = "api/user/verify?u=" + emailToCheck;

            StartCoroutine(ApiManager.Instance.GetWithToken(url, success, fail));
        }
        // Update is called once per frame
        void Update()
        {
            if (this.isActiveAndEnabled & !TacoManager.CheckModalsOpen())
            {
                // validate requirements
                RegisterButtonImage.sprite = NotOkay;
                bool emailValidated    = false;
                bool userValidated     = false;
                bool passwordValidated = false;



                if (PasswordInput.GetComponent <InputField> ().text == "" || ConfirmInput.GetComponent <InputField> ().text == "")
                {
                    StatusText.GetComponent <Text> ().text = TacoConfig.TacoRegisteredErrorMessage04;
                }



                if (UserInput.GetComponent <InputField> ().text == "")
                {
                    StatusText.GetComponent <Text> ().text = TacoConfig.TacoRegisteredErrorMessage03;
                }


                if (UserInput.GetComponent <InputField> ().text != "")
                {
                    userValidated = true;
                    UserOkay.SetActive(true);
                }
                else
                {
                    userValidated = false;
                    StatusText.GetComponent <Text> ().text = TacoConfig.TacoRegisteredErrorMessage03;
                    UserOkay.SetActive(false);
                }

                if (string.IsNullOrEmpty(EmailInput.GetComponent <InputField> ().text))
                {
                    emailValidated = false;
                    EmailOkay.SetActive(false);
                    StatusText.GetComponent <Text> ().text = TacoConfig.TacoRegisteredErrorMessage06;
                }
                else
                {
                    var  textEmail = EmailInput.GetComponent <InputField> ().text;
                    bool isEmail   = TacoManager.ValidateEmail(textEmail);
                    StatusText.GetComponent <Text> ().text = TacoConfig.TacoRegisteredErrorMessage01;
                    if (isEmail == true)
                    {
                        emailValidated = true;

                        StatusText.GetComponent <Text> ().text = TacoConfig.TacoRegisteredErrorMessage04;
                        EmailOkay.SetActive(true);
                    }
                    else
                    {
                        emailValidated = false;
                        StatusText.GetComponent <Text> ().text = TacoConfig.TacoRegisteredErrorMessage01;
                        EmailOkay.SetActive(false);
                    }
                }


                if (PasswordInput.GetComponent <InputField> ().text != "" && ConfirmInput.GetComponent <InputField> ().text != "")
                {
                    if (ConfirmInput.GetComponent <InputField> ().text == PasswordInput.GetComponent <InputField> ().text)
                    {
                        if (PasswordInput.GetComponent <InputField> ().text.Length > 3)
                        {
                            passwordValidated = true;
                            //StatusText.GetComponent<Text> ().text = "";

                            PasswordOkay.SetActive(true);
                            ConfirmOkay.SetActive(true);
                        }
                        else
                        {
                            passwordValidated = false;
                            StatusText.GetComponent <Text> ().text = TacoConfig.TacoRegisteredErrorMessage07;

                            PasswordOkay.SetActive(false);
                            ConfirmOkay.SetActive(false);
                        }
                    }
                    else
                    {
                        passwordValidated = false;
                        StatusText.GetComponent <Text> ().text = TacoConfig.TacoRegisteredErrorMessage00;

                        PasswordOkay.SetActive(false);
                        ConfirmOkay.SetActive(false);
                    }
                }
                else
                {
                    //StatusText.GetComponent<Text> ().text = TacoConfig.TacoRegisteredErrorMessage04;
                    passwordValidated = false;
                    PasswordOkay.SetActive(false);
                    ConfirmOkay.SetActive(false);
                }

                // test all conditions
                if (userValidated && passwordValidated && emailValidated && AgeToggle.GetComponent <Toggle> ().isOn)
                {
                    RegisterButtonImage.sprite = Okay;

                    StatusText.GetComponent <Text> ().text = TacoConfig.TacoRegisteredAllOkay;
                }
                else if (userValidated && passwordValidated && emailValidated && !AgeToggle.GetComponent <Toggle> ().isOn)
                {
                    StatusText.GetComponent <Text> ().text = TacoConfig.TacoRegisteredErrorMessage02;
                }
                else
                {
                    RegisterButtonImage.sprite = NotOkay;
                }



                // turn off placeholders on focus
                if (this.isActiveAndEnabled & !TacoManager.CheckModalsOpen())
                {
                    // tab through inputs
                    if (Input.GetKeyDown(KeyCode.Tab))
                    {
                        if (UserInput.GetComponent <InputField> ().isFocused)
                        {
                            EmailInput.GetComponent <InputField> ().ActivateInputField();
                        }
                        else if (EmailInput.GetComponent <InputField> ().isFocused)
                        {
                            PasswordInput.GetComponent <InputField> ().ActivateInputField();
                        }
                        else if (PasswordInput.GetComponent <InputField> ().isFocused)
                        {
                            ConfirmInput.GetComponent <InputField> ().ActivateInputField();
                        }
                        else if (ConfirmInput.GetComponent <InputField> ().isFocused)
                        {
                            UserInput.GetComponent <InputField> ().ActivateInputField();
                        }
                        else
                        {
                            UserInput.GetComponent <InputField> ().ActivateInputField();
                        }
                    }
                    else if (Input.GetKeyDown(KeyCode.Return))
                    {
                        Register();
                    }
                }
            }
        }
        private bool validateInput()
        {
            var  email     = EmailInput.GetComponent <InputField>().text;
            var  password  = PasswordInput.GetComponent <InputField>().text;
            var  confirm   = ConfirmInput.GetComponent <InputField>().text;
            var  age       = AgeToggle.GetComponent <Toggle>().isOn;
            var  user      = UserInput.GetComponent <InputField>().text;
            bool validated = true;

            if (string.IsNullOrEmpty(password) || string.IsNullOrEmpty(confirm))
            {
                validated = false;
                StatusText.GetComponent <Text> ().text = TacoConfig.TacoRegisteredErrorMessage04;
            }

            if (string.IsNullOrEmpty(email))
            {
                validated = false;
                StatusText.GetComponent <Text> ().text = TacoConfig.TacoRegisteredErrorMessage06;
            }
            else
            {
                bool isEmail = TacoManager.ValidateEmail(email);

                if (!isEmail)
                {
                    validated = false;
                    StatusText.GetComponent <Text> ().text = TacoConfig.TacoRegisteredErrorMessage01;
                }
            }

            if (string.IsNullOrEmpty(user))
            {
                validated = false;
                StatusText.GetComponent <Text> ().text = TacoConfig.TacoRegisteredErrorMessage03;
            }

            if (!string.IsNullOrEmpty(password) && !string.IsNullOrEmpty(confirm))
            {
                StatusText.GetComponent <Text> ().text = TacoConfig.TacoRegisteredErrorMessage04;

                if (password == confirm)
                {
                    if (password.Length <= 3)
                    {
                        validated = false;
                        StatusText.GetComponent <Text> ().text = TacoConfig.TacoRegisteredErrorMessage07;
                    }
                }
                else
                {
                    validated = false;
                    StatusText.GetComponent <Text> ().text = TacoConfig.TacoRegisteredErrorMessage00;
                }
            }
            else
            {
                validated = false;
                StatusText.GetComponent <Text> ().text = TacoConfig.TacoRegisteredErrorMessage04;
            }
            if (!age)
            {
                validated = false;
                StatusText.GetComponent <Text> ().text = TacoConfig.TacoRegisteredErrorMessage02;
            }
            return(validated);
        }