Example #1
0
            public static async Task EnsureTestUserExists(bool staySignedIn, string email, string pass)
            {
                string debugPrefix = "EnsureTestUserExists: ";

                Debug.Log(debugPrefix + "Begin");
                // find existing test user if any
                FirebaseAuth        firebase  = FirebaseAuth.DefaultInstance;
                Task <FirebaseUser> loginTask = firebase.SignInWithEmailAndPasswordAsync(email, pass);
                FirebaseUser        user;

                try
                {
                    user = await loginTask;
                }
                catch (AggregateException)
                {
                    // user does not exist so we create it
                    Task <FirebaseUser> createUserTask = firebase.CreateUserWithEmailAndPasswordAsync(Constants.TEST_EMAIL, Constants.TEST_PASSWORD);
                    try
                    {
                        user = await createUserTask;
                    }
                    catch (AggregateException)
                    {
                        // failed to create user
                        Debug.LogError(debugPrefix + "Failed to Create Test User: "******"StateChanged");
                    firebase.SignOut();
                    await nextAuthEvent;
                }



                Debug.Log(debugPrefix + "Finish");
                return;
            }