Exemplo n.º 1
0
    // private void AuthStateChanged(object sender, EventArgs eventArgs)
    // {
    //     if (FirebaseManager.auth.CurrentUser != FirebaseManager.user)
    //     {
    //         bool signedIn = FirebaseManager.user != FirebaseManager.auth.CurrentUser && FirebaseManager.auth.CurrentUser != null;
    //         if (!signedIn && FirebaseManager.user != null)
    //         {
    //             Debug.Log("Signed out " + FirebaseManager.user.UserId);
    //             ActionManager.Instance.ShowSignInPanel();

    //             FirebaseManager.UserDatabaseReference = FirebaseManager.UserNullDatabaseReference;
    //         }
    //         FirebaseManager.user = FirebaseManager.auth.CurrentUser;
    //         if (signedIn)
    //         {
    //             Debug.Log("Signed in " + FirebaseManager.user.UserId);
    //             FirebaseManager.displayName = FirebaseManager.user.DisplayName ?? "";
    //             FirebaseManager.emailAddress = FirebaseManager.user.Email ?? "";
    //             FirebaseManager.SetUserDatabaseReference();
    //	ActionManager.Instance.GetCurrentUserProfile();
    //}
    //     }
    //     else
    //     {
    //         Debug.Log("Kullanıcı yok galiba");
    //     }
    // }

    #region Sign Up

    private IEnumerator SignUpWithEmailPassword(SignUpStruct signUpStruct, Action onSuccessCallback, Action onFailCallback)
    {
        Task task = FirebaseManager.auth.CreateUserWithEmailAndPasswordAsync(signUpStruct.Email, signUpStruct.Password);

        yield return(new WaitUntil(() => task.IsCanceled || task.IsFaulted || task.IsCompleted));

        if (task.IsCanceled)
        {
            //LogTaskCompletion(task, "Giriş işlemi iptal edildi");
            Debug.LogWarning(AuthenticationsDebugs.SignUp + DebugPaths.IsCanceled);
        }
        else if (task.IsFaulted)
        {
            onFailCallback();
            Debug.LogError(AuthenticationsDebugs.SignUp + DebugPaths.IsFaulted);
        }
        else if (task.IsCompleted)
        {
            //FirebaseManager.SetUserDatabaseReference();

            EventManager.Instance.CreatUserProfile(signUpStruct.Username, signUpStruct.Language);

            onSuccessCallback();
            Debug.Log(AuthenticationsDebugs.SignUp + DebugPaths.IsCompleted);
        }
    }
Exemplo n.º 2
0
    private void SignUp()
    {
        SignUpStruct signUpStruct = new SignUpStruct();

        signUpStruct.Username        = inputField_Username.textComponent.text.Replace("\u200B", "");
        signUpStruct.Email           = inputField_Email.textComponent.text.Replace("\u200B", "");
        signUpStruct.Password        = inputField_Password.textComponent.text.Replace("\u200B", "");
        signUpStruct.ConfirmPassword = inputField_ConfirmPassword.textComponent.text.Replace("\u200B", "");

        if (toggle_EnglishLanguage.isOn)
        {
            signUpStruct.Language = text_EnglishToggle.text;
        }
        else if (toggle_TurkishLanguage.isOn)
        {
            signUpStruct.Language = text_TurkishToggle.text;
        }

        Debug.Log(signUpStruct.Language);

        StartCoroutine(EventManager.Instance.SignUpWithEmailPassword(signUpStruct, SignUpWithEmailPasswordSuccesful, SignUpWithEmailPasswordFailed));
    }