public void ButtonLogin()
 {
     if (TestEmail.IsEmail(inputFieldEmail.text) && inputFieldEmail.text != "" && inputFieldPassword.text != "" && inputFieldEmail.text != " " && inputFieldPassword.text != " ")
     {
         if (Application.internetReachability == NetworkReachability.NotReachable)
         {
             textWarning.text = "Error. Check internet connection!";
         }
         else
         {
             panelLoading.SetActive(true); ok = true;
             FirebaseApp.CheckAndFixDependenciesAsync().ContinueWith(task =>
             {
                 if (task.Result == DependencyStatus.Available)
                 {
                     InitializeFirebase();
                 }
                 else
                 {
                     Debug.LogError(
                         "Could not resolve all Firebase dependencies: " + task.Result);
                 }
             });
         }
     }
     else
     {
         textWarning.color = Color.red;
         textWarning.text  = "Please Check Your Email Or Password";
     }
 }
Esempio n. 2
0
        /// <summary>
        /// Validates the email.
        /// </summary>
        /// <returns><c>true</c>, if email was validated, <c>false</c> otherwise.</returns>
        private bool ValidateEmail()
        {
            // validate email
            if (email == null || string.IsNullOrEmpty(email.text))
            {
                feedbackMessage.ShowMessage("Please enter an email.", FeedbackMessagePanel.StyleType.ERROR);
                return(false);
            }
            else if (!TestEmail.IsEmail(email.text))
            {
                feedbackMessage.ShowMessage("Invalid email.", FeedbackMessagePanel.StyleType.ERROR);
                return(false);
            }

            return(true);
        }
    // ------------- Evaluate user data ----------------- //

    bool EvaluateUserData(bool silent = false)
    {
        foreach (string name in inputFieldsNames)
        {
            if (inputFields [name].text.Length == 0)
            {
                if (!silent)
                {
                    InformationMessage("You should complete the '" + name + "' field to suscribe");
                }
                return(false);
            }
        }

        if (!toggles ["Male"].isOn && !toggles ["Female"].isOn)
        {
            if (!silent)
            {
                InformationMessage("You should choose a gender to suscribe");
            }
            return(false);
        }

        if (!toggles ["Consent"].isOn)
        {
            if (!silent)
            {
                InformationMessage("You should give your consent to suscribe");
            }
            return(false);
        }

        if (!TestEmail.IsEmail(inputFields ["Email"].text))
        {
            if (!silent)
            {
                InformationMessage("You should give a valid email to be able to receive a password");
            }
            return(false);
        }

        return(true);
    }
Esempio n. 4
0
 private void Signin(string email, string pass)
 {
     if (!TestEmail.IsEmail(email_login.text))
     {
         Debug.Log("Неверно введен Email");
         return;
     }
     if (password_login.text.Length < 6)
     {
         Debug.Log("Пароль должен быть больше 6-ти символов");
         return;
     }
     gameManager.ShowLoading(true);
     Debug.Log("we are here");
     Email    = email;
     Password = pass;
     Auth.SignInWithEmailAndPasswordAsync(email, pass).ContinueWithOnMainThread(authTask =>
     {
         if (authTask.IsCanceled)
         {
             Debug.LogError("SignInWithEmailAndPasswordAsync was canceled.");
             gameManager.ShowLoading(false);
             return;
         }
         if (authTask.IsFaulted)
         {
             Debug.LogError("SignInWithEmailAndPasswordAsync encountered an error: " + authTask.Exception);
             gameManager.ShowLoading(false);
             return;
         }
         if (authTask.IsCompleted && authTask.Result != null)
         {
             User = authTask.Result;
         }
     });
 }
    public void SignUp()
    {
        if (TestEmail.IsEmail(inputFieldEmail.text) && inputFieldEmail.text != "" && inputFieldPassword.text != "" && inputFieldEmail.text != " " && inputFieldEmail.text != " " && inputFieldNickName.text != "" && inputFieldNickName.text != " " && inputFieldPasswordAgain.text != "" && inputFieldPasswordAgain.text != " " && inputFieldPassword.text == inputFieldPasswordAgain.text)
        {
            if (Application.internetReachability == NetworkReachability.NotReachable)
            {
                textWarning.text = "Error. Check internet connection!";
            }
            else
            {
                panelLoading.SetActive(true); ok = true;
                VariablesRealTime.auth.CreateUserWithEmailAndPasswordAsync(inputFieldEmail.text, inputFieldPassword.text).ContinueWith(task =>
                {
                    if (task.IsCanceled)
                    {
                        panelLoading.SetActive(false); ok = false;
                        Debug.LogError("CreateUserWithEmailAndPasswordAsync was canceled.");
                        AggregateException ex = task.Exception as AggregateException;
                        if (ex != null)
                        {
                            Firebase.FirebaseException fbEx = null;
                            foreach (Exception e in ex.InnerExceptions)
                            {
                                fbEx = e as Firebase.FirebaseException;
                                if (fbEx != null)
                                {
                                    break;
                                }
                            }

                            if (fbEx != null)
                            {
                                textWarning.color = Color.red;
                                textWarning.text  = fbEx.Message;
                            }
                        }
                        return;
                    }
                    if (task.IsFaulted)
                    {
                        panelLoading.SetActive(false); ok = false;
                        Debug.LogError("CreateUserWithEmailAndPasswordAsync encountered an error: " + task.Exception);
                        AggregateException ex = task.Exception as AggregateException;
                        if (ex != null)
                        {
                            Firebase.FirebaseException fbEx = null;
                            foreach (Exception e in ex.InnerExceptions)
                            {
                                fbEx = e as Firebase.FirebaseException;
                                if (fbEx != null)
                                {
                                    break;
                                }
                            }

                            if (fbEx != null)
                            {
                                textWarning.color = Color.red;
                                textWarning.text  = fbEx.Message;
                            }
                        }
                        return;
                    }
                    if (task.IsCompleted)
                    {
                        textWarning.color = Color.green;

                        textWarning.text = "Count Created";

                        FirebaseApp.DefaultInstance.SetEditorDatabaseUrl("https://snowballs-98497.firebaseio.com/");

                        DatabaseReference reference = FirebaseDatabase.DefaultInstance.RootReference;

                        User user = new User
                                    (
                            inputFieldNickName.text,

                            inputFieldEmail.text,

                            inputFieldPassword.text,

                            task.Result.UserId,

                            1,

                            0,

                            0,

                            100f
                                    );

                        VariablesRealTime.eMail = inputFieldEmail.text;

                        VariablesRealTime.password = inputFieldPassword.text;

                        VariablesRealTime.newUser = task.Result;

                        string json = JsonUtility.ToJson(user);

                        reference.Child("users").Child(task.Result.UserId).SetRawJsonValueAsync(json).ContinueWith((task3) =>
                        {
                            if (task3.IsFaulted)
                            {
                                textWarning.text = task3.Exception.Message;

                                panelLoading.SetActive(false); ok = false;

                                return;
                            }
                            if (task3.IsCompleted)
                            {
                                SceneManager.LoadScene("Main");
                            }
                        });
                    }
                });
            }
        }
        else
        {
            textWarning.text = "Please Check Your Email Or Password Or Your User Name";
        }
        {
            if (inputFieldPasswordAgain.text != inputFieldPassword.text)
            {
                textWarning.color = Color.red;
                textWarning.text  = "Your Password Does Not Match";
            }
        }
    }
Esempio n. 6
0
    public void OnPressButtonSignUp()
    {
        if (TestEmail.IsEmail(inputFieldEmail.text) && inputFieldNickName.text != "" && inputFieldNickName.text != " " && inputFieldEmail.text != "" && inputFieldEmail.text != "" && inputFieldEmail.text != " " && inputFieldEmail.text != " " && inputFieldConfirmPassword.text != "" && inputFieldConfirmPassword.text != " " && inputFieldPassword.text == inputFieldConfirmPassword.text)
        {
            if (Application.internetReachability == NetworkReachability.NotReachable)
            {
                textLogError.text = "Error. Check internet connection!";
            }
            else
            {
                panelLoading.SetActive(true);
                FirebaseApp.CheckAndFixDependenciesAsync().ContinueWith(task1 => {
                    var dependencyStatus = task1.Result;
                    if (dependencyStatus == DependencyStatus.Available)
                    {
                        Session.auth = Firebase.Auth.FirebaseAuth.DefaultInstance;
                        Session.auth.CreateUserWithEmailAndPasswordAsync(inputFieldEmail.text, inputFieldPassword.text).ContinueWith(task2 => { //This line creates a new user
                            if (task2.IsCanceled)
                            {
                                panelLoading.SetActive(false);
                                Debug.LogError("CreateUserWithEmailAndPasswordAsync was canceled.");
                                AggregateException exception = task2.Exception as AggregateException;
                                if (exception != null)
                                {
                                    FirebaseException fireBaseException = null;
                                    foreach (Exception e in exception.InnerExceptions)
                                    {
                                        fireBaseException = e as FirebaseException;
                                        if (fireBaseException != null)
                                        {
                                            break;
                                        }
                                    }

                                    if (fireBaseException != null)
                                    {
                                        Debug.LogError("CreateUserWithEmailAndPasswordAsync encountered an error: " + fireBaseException.Message);
                                        textLogError.text = fireBaseException.Message;
                                    }
                                }
                                return;
                            }
                            if (task2.IsFaulted)
                            {
                                panelLoading.SetActive(false);
                                Debug.LogError("CreateUserWithEmailAndPasswordAsync was faulted.");
                                AggregateException exception = task2.Exception as AggregateException;
                                if (exception != null)
                                {
                                    FirebaseException fireBaseException = null;
                                    foreach (Exception e in exception.InnerExceptions)
                                    {
                                        fireBaseException = e as FirebaseException;
                                        if (fireBaseException != null)
                                        {
                                            break;
                                        }
                                    }

                                    if (fireBaseException != null)
                                    {
                                        Debug.LogError("CreateUserWithEmailAndPasswordAsync encountered an error: " + fireBaseException.Message);
                                        textLogError.text = fireBaseException.Message;
                                    }
                                }
                                return;
                            }
                            if (task2.IsCompleted)
                            {
                                Session.auth.SignInWithEmailAndPasswordAsync(inputFieldEmail.text, inputFieldPassword.text).ContinueWith(task3 => {
                                    if (task3.IsCanceled)
                                    {
                                        panelLoading.SetActive(false);
                                        Debug.LogError("SignInWithEmailAndPasswordAsync was canceled.");
                                        AggregateException exception = task3.Exception as AggregateException;
                                        if (exception != null)
                                        {
                                            FirebaseException fireBaseException = null;
                                            foreach (Exception e in exception.InnerExceptions)
                                            {
                                                fireBaseException = e as FirebaseException;
                                                if (fireBaseException != null)
                                                {
                                                    break;
                                                }
                                            }

                                            if (fireBaseException != null)
                                            {
                                                Debug.LogError("SignInWithEmailAndPasswordAsync encountered an error: " + fireBaseException.Message);
                                                textLogError.text = fireBaseException.Message;
                                            }
                                        }
                                        return;
                                    }
                                    if (task3.IsFaulted)
                                    {
                                        panelLoading.SetActive(false);
                                        Debug.LogError("SignInWithEmailAndPasswordAsync was faulted.");
                                        AggregateException exception = task3.Exception as AggregateException;
                                        if (exception != null)
                                        {
                                            FirebaseException fireBaseException = null;
                                            foreach (Exception e in exception.InnerExceptions)
                                            {
                                                fireBaseException = e as FirebaseException;
                                                if (fireBaseException != null)
                                                {
                                                    break;
                                                }
                                            }

                                            if (fireBaseException != null)
                                            {
                                                Debug.LogError("SignInWithEmailAndPasswordAsync encountered an error: " + fireBaseException.Message);
                                                textLogError.text = fireBaseException.Message;
                                            }
                                        }
                                        return;
                                    }
                                    if (task3.IsCompleted)
                                    {
                                        FirebaseApp.DefaultInstance.SetEditorDatabaseUrl("https://tomaelcontrol-830dd.firebaseio.com/");                    //Here you should change for you base data link!!!!
                                        DatabaseReference reference = FirebaseDatabase.DefaultInstance.RootReference;
                                        string json = JsonUtility.ToJson(new User(inputFieldEmail.text, inputFieldPassword.text, inputFieldNickName.text)); // This line creates a reference in the database for the current user
                                        reference.Child("users").Child(Session.auth.CurrentUser.UserId).SetRawJsonValueAsync(json).ContinueWith(task4 => {
                                            if (task4.IsCanceled)
                                            {
                                                panelLoading.SetActive(false);
                                                Debug.LogError("SetRawJsonValueAsync was canceled.");
                                                AggregateException exception = task4.Exception as AggregateException;
                                                if (exception != null)
                                                {
                                                    FirebaseException fireBaseException = null;
                                                    foreach (Exception e in exception.InnerExceptions)
                                                    {
                                                        fireBaseException = e as FirebaseException;
                                                        if (fireBaseException != null)
                                                        {
                                                            break;
                                                        }
                                                    }

                                                    if (fireBaseException != null)
                                                    {
                                                        Debug.LogError("SetRawJsonValueAsync encountered an error: " + fireBaseException.Message);
                                                        textLogError.text = fireBaseException.Message;
                                                    }
                                                }
                                                return;
                                            }
                                            if (task4.IsFaulted)
                                            {
                                                panelLoading.SetActive(false);
                                                Debug.LogError("SetRawJsonValueAsync was faulted.");
                                                AggregateException exception = task4.Exception as AggregateException;
                                                if (exception != null)
                                                {
                                                    FirebaseException fireBaseException = null;
                                                    foreach (Exception e in exception.InnerExceptions)
                                                    {
                                                        fireBaseException = e as FirebaseException;
                                                        if (fireBaseException != null)
                                                        {
                                                            break;
                                                        }
                                                    }

                                                    if (fireBaseException != null)
                                                    {
                                                        Debug.LogError("SetRawJsonValueAsync encountered an error: " + fireBaseException.Message);
                                                        textLogError.text = fireBaseException.Message;
                                                    }
                                                }
                                                return;
                                            }
                                            if (task4.IsCompleted)
                                            {
                                                Session.auth.CurrentUser.SendEmailVerificationAsync().ContinueWith(task5 => {
                                                    if (task5.IsFaulted)
                                                    {
                                                        textLogError.text = "Something was wrong, Please check your data!";
                                                    }
                                                    if (task5.IsCanceled)
                                                    {
                                                        textLogError.text = "Something was wrong, Please check your data!";
                                                    }
                                                    if (task5.IsCompleted)
                                                    {
                                                        CreateSpeakerSection();
                                                    }
                                                });
                                            }
                                        });
                                    }
                                });
                            }
                        });
                    }
                    else
                    {
                        Debug.LogError(String.Format("Could not resolve all Firebase dependencies: {0}", dependencyStatus));
                    }
                });
            }
        }
        else
        {
            textLogError.text = "Please Check Your data";

            if (inputFieldPassword.text != inputFieldConfirmPassword.text)
            {
                textLogError.text = "Your Password Does Not Match";
            }
        }
    }
Esempio n. 7
0
    public void OnPressButtonSignIn()
    {
        if (TestEmail.IsEmail(inputFieldEmail.text) && inputFieldEmail.text != "" && inputFieldPassword.text != "" && inputFieldEmail.text != " " && inputFieldPassword.text != " ")
        {
            if (Application.internetReachability == NetworkReachability.NotReachable)
            {
                textLogError.text = "Error. Check internet connection!";
            }
            else
            {
                panelLoading.SetActive(true);
                FirebaseApp.CheckAndFixDependenciesAsync().ContinueWith(task1 => {
                    var dependencyStatus = task1.Result;
                    if (dependencyStatus == DependencyStatus.Available)
                    {
                        Session.auth = Firebase.Auth.FirebaseAuth.DefaultInstance;

                        //if (Session.auth.CurrentUser.IsEmailVerified)
                        //{
                        Debug.Log("DefaultInstance");
                        Session.auth.SignInWithEmailAndPasswordAsync(inputFieldEmail.text, inputFieldPassword.text).ContinueWith(task2 =>
                        {
                            if (task2.IsCanceled)
                            {
                                panelLoading.SetActive(false);
                                Debug.LogError("SignInWithEmailAndPasswordAsync was canceled.");
                                AggregateException exception = task2.Exception as AggregateException;
                                if (exception != null)
                                {
                                    FirebaseException fireBaseException = null;
                                    foreach (Exception e in exception.InnerExceptions)
                                    {
                                        fireBaseException = e as FirebaseException;
                                        if (fireBaseException != null)
                                        {
                                            break;
                                        }
                                    }

                                    if (fireBaseException != null)
                                    {
                                        Debug.LogError("SignInWithEmailAndPasswordAsync encountered an error: " + fireBaseException.Message);
                                        textLogError.text = fireBaseException.Message;
                                    }
                                }
                                return;
                            }
                            if (task2.IsFaulted)
                            {
                                panelLoading.SetActive(false);
                                Debug.Log("IsFaulted");
                                Debug.LogError("SignInWithEmailAndPasswordAsync was faulted.");
                                AggregateException exception = task2.Exception as AggregateException;
                                if (exception != null)
                                {
                                    FirebaseException fireBaseException = null;
                                    foreach (Exception e in exception.InnerExceptions)
                                    {
                                        fireBaseException = e as FirebaseException;
                                        if (fireBaseException != null)
                                        {
                                            break;
                                        }
                                    }

                                    if (fireBaseException != null)
                                    {
                                        Debug.LogError("CreateUserWithEmailAndPasswordAsync encountered an error: " + fireBaseException.Message);
                                        textLogError.text = fireBaseException.Message;
                                    }
                                }
                                return;
                            }
                            if (task2.IsCompleted)
                            {
                                UnityMainThread.wkr.AddJob(() =>
                                {
                                    LoadNextScene();
                                });
                            }
                        });
                        // }
                        //  else
                        //  {
                        //   UnityMainThread.wkr.AddJob(() =>
                        //     {
                        //   panelLoading.SetActive(false);
                        //        textLogError.text = "Please you has to verify your email";
                        // });
                        //  }
                    }
                    else
                    {
                        Debug.LogError(String.Format(
                                           "Could not resolve all Firebase dependencies: {0}", dependencyStatus));
                    }
                });
            }
        }
        else
        {
            panelLoading.SetActive(false);
            textLogError.text = "Please Check Your Email Or Password";
        }
    }
Esempio n. 8
0
    public void NewRegister()
    {
        if (tremsOfUseToggle.GetComponentInChildren <Toggle>().isOn&& labaRulesToggle.GetComponentInChildren <Toggle>().isOn)
        {
            string number = Verificator.IsValidPhoneNumber(phone_register.text);
            if (number == null)
            {
                Debug.Log("Неверно введен номер телефона");
                return;
            }
            if (!TestEmail.IsEmail(email_register.text))
            {
                Debug.Log("Неверно введен Email");
                return;
            }
            if (password_register.text.Trim().Length < 6)
            {
                Debug.Log("Пароль должен быть больше 6-ти символов");
                return;
            }
            if (name_register.text.Trim().Length < 2)
            {
                Debug.Log("Введите Имя");
                return;
            }
            if (lastName_register.text.Trim().Length < 1)
            {
                Debug.Log("Введите Фамилию");
                return;
            }
            if (patronymic_register.text.Trim().Length < 2)
            {
                Debug.Log("Введите Отчество");
                return;
            }


            Email        = email_register.text;
            Password     = password_register.text;
            Phone_Number = number;
            Name         = name_register.text;
            LastName     = lastName_register.text;
            Patronymic   = patronymic_register.text;
            Birthday     = "" + birthday_register[0].options[birthday_register[0].value].text + "/"
                           + birthday_register[1].options[birthday_register[1].value].text + "/"
                           + birthday_register[2].options[birthday_register[2].value].text;
            gameManager.ShowLoading(true);

            uint phoneAuthTimeoutMs = 60 * 1000;
            Provider = PhoneAuthProvider.GetInstance(Auth);
            Provider.VerifyPhoneNumber(Phone_Number, phoneAuthTimeoutMs, null,
                                       verificationCompleted: (credential) =>
            {
                Debug.Log("Completed");
                SignInAndUpdate(credential);
            },
                                       verificationFailed: (error) =>
            {
                Debug.Log("error");
                Debug.Log(error);
                gameManager.ShowLoading(false);
            },
                                       codeSent: (id, token) =>
            {
                Debug.Log(id);
                verificationId = id;
                gameManager.Panels[1].GetComponent <Animator>().Play("SSCR Fade-out");
                gameManager.Panels[2].GetComponent <Animator>().Play("SSCR Fade-in");
                gameManager.ShowLoading(false);
            },
                                       codeAutoRetrievalTimeOut: (id) =>
            {
                Debug.Log("Phone Auth, auto-verification timed out");
                gameManager.ShowLoading(false);
            });
        }
    }