void GetErrorMessage(AuthError errorCode)
    {
        string msg = "";

        msg = errorCode.ToString();
        print(msg);

        //switch (errorCode)
        //{
        //    case AuthError.AccountExistsWithDifferentCredentials:
        //        Console("Email já foi utilizado anteriormente");
        //        break;
        //    case AuthError.MissingEmail:
        //        Console("Insira o email");
        //        break;
        //    case AuthError.MissingPassword:
        //        Console("Insira a senha");
        //        break;
        //    case AuthError.WrongPassword:
        //        Console("Senha incorreta");
        //        break;
        //    case AuthError.InvalidEmail:
        //        Console("Email inválido");
        //        break;
        //    case AuthError.WeakPassword:
        //        Console("A senha deve ter no mínimo seis digitos");
        //        break;
        //}
    }
Exemplo n.º 2
0
    void GetErrorMessage(AuthError errorCode)
    {
        string msg = "";

        msg = errorCode.ToString();
        print(msg);
    }
Exemplo n.º 3
0
    private Task RegisterToDB_ReturnTask()     // Note the return type, not async
    {
        return(FirebaseAuth.DefaultInstance.CreateUserWithEmailAndPasswordAsync(emailInput.text, passwordInput.text).ContinueWith(task => {
            if (task.IsCanceled)
            {
                Firebase.FirebaseException e = task.Exception.Flatten().InnerExceptions[0] as Firebase.FirebaseException;

                AuthError msg = (AuthError)e.ErrorCode;
                registerError = msg.ToString();
                print("Error: " + registerError);

                return;
            }
            if (task.IsFaulted)
            {
                Firebase.FirebaseException e = task.Exception.Flatten().InnerExceptions[0] as Firebase.FirebaseException;

                AuthError msg = (AuthError)e.ErrorCode;
                registerError = msg.ToString();
                print("Error: " + registerError);

                return;
            }
            if (task.IsCompleted)
            {
                print("Registration complete successfully!");
                registerSuccessful = true;
            }
            return;
        }));
    }
Exemplo n.º 4
0
    void GetErrorMessage(AuthError errorCode)
    {
        string msg = errorCode.ToString();

        print(msg);
        lastStatus = msg;
    }
    public IEnumerator fazLogin()
    {
        string meuLogin   = login.text;
        string minhaSenha = senha.text;

        var LoginTask = auth.SignInWithEmailAndPasswordAsync(meuLogin, minhaSenha);

        yield return(new WaitUntil(predicate: () => LoginTask.IsCompleted));

        if (LoginTask.Exception != null)
        {
            SceneManager.LoadScene("erro");

            FirebaseException fex = LoginTask.Exception.GetBaseException() as FirebaseException;

            AuthError ae = (AuthError)fex.ErrorCode;

            print(fex.Message);
            print(ae.ToString());
        }
        else
        {
            //SceneManager.LoadScene("ok");

            //LOAD DATA
            username = login.text;
            StartCoroutine(loadUserData());
            //GO TO PAGE
            goToDatabasePage();
        }
    }
Exemplo n.º 6
0
    private Task LoginToDB_ReturnTask()     // Note the return type, not async
    {
        return(FirebaseAuth.DefaultInstance.SignInWithEmailAndPasswordAsync(emailInput.text, passwordInput.text).ContinueWith(task => {
            if (task.IsCanceled)
            {
                Firebase.FirebaseException e = task.Exception.Flatten().InnerExceptions[0] as Firebase.FirebaseException;

                AuthError msg = (AuthError)e.ErrorCode;
                loginError = msg.ToString();
                print("Error: " + loginError);

                return;
            }
            if (task.IsFaulted)
            {
                Firebase.FirebaseException e = task.Exception.Flatten().InnerExceptions[0] as Firebase.FirebaseException;

                AuthError msg = (AuthError)e.ErrorCode;
                loginError = msg.ToString();
                print("Error: " + loginError);

                return;
            }
            if (task.IsCompleted)
            {
                print("Login successful!");
                loginSuccessful = true;
            }
            return;
        }));
    }
Exemplo n.º 7
0
    void GetErrorMessage(AuthError errorCode)
    {
        string msg = "";

        msg = errorCode.ToString();

        //switch(errorCode) {

        //    case AuthError.AccountExistsWithDifferentCredentials:
        //        // CODE
        //        break;

        //    case AuthError.MissingPassword:
        //        break;

        //    case AuthError.WrongPassword:
        //        break;

        //    case AuthError.InvalidEmail:
        //        break;

        //}


        print(msg);
    }
Exemplo n.º 8
0
    private void GetErrorMessage(AuthError err)
    {
        switch (err)
        {
        case AuthError.AccountExistsWithDifferentCredentials:
            print("Account already exists, please use another one");
            break;

        case AuthError.MissingPassword:
            print("Missing password");
            break;

        case AuthError.WrongPassword:
            print("Wrong password");
            break;

        case AuthError.InvalidEmail:
            print("Invalid email");
            break;
        }
        print(err.ToString());
        outputText.text = err.ToString();
    }
    private string GetErrorMessage(AuthError errorCode)
    {
        var message = "";

        Debug.Log("MyTag!!" + errorCode.ToString());
        switch (errorCode)
        {
        case AuthError.AccountExistsWithDifferentCredentials:
            message = "Já existe uma conta com credenciais diferentes.";
            break;

        case AuthError.MissingPassword:
            message = "É obrigatório o uso de uma senha";
            break;

        case AuthError.WeakPassword:
            message = "Senha muito fraca, é necessário ao menos 6 caracteres.";
            break;

        case AuthError.WrongPassword:
            message = "Senha incorreta";
            break;

        case AuthError.EmailAlreadyInUse:
            message = "Esse email já está sendo usado.";
            break;

        case AuthError.InvalidEmail:
            message = "Email inválido";
            break;

        case AuthError.MissingEmail:
            message = "É obrigatório o uso de uma senha";
            break;

        case AuthError.UserNotFound:
            message = "Usuário não encontrado";
            break;

        case AuthError.NetworkRequestFailed:
            message = "Sem conexão! Verifique a internet e tente novamente!";
            break;

        default:
            message = "Ocorreu um erro. Tente novamente mais tarde!";
            break;
        }
        return(message);
    }
Exemplo n.º 10
0
    void GetErrorMessage(AuthError errorCode)
    {
        string msg = "";

        msg = errorCode.ToString();

        // switch (errorCode)
        // {
        //     case AuthError.MissingPassword:
        //         break;
        //     // TODO
        // }

        print(msg);
    }
    public Task LoadDataManager(string activityName, string activityLevel)
    {
        return(databaseReference.Child(usrEmail + "_" + activityName + "_" + activityLevel).GetValueAsync().ContinueWith((task => {
            if (task.IsCanceled)
            {
                Firebase.FirebaseException e = task.Exception.Flatten().InnerExceptions[0] as Firebase.FirebaseException;

                AuthError msg = (AuthError)e.ErrorCode;
                loadError = msg.ToString();
                print("Error: " + loadError);
            }
            if (task.IsFaulted)
            {
                Firebase.FirebaseException e = task.Exception.Flatten().InnerExceptions[0] as Firebase.FirebaseException;

                AuthError msg = (AuthError)e.ErrorCode;
                loadError = msg.ToString();
                print("Error: " + loadError);
            }
            if (task.IsCompleted)
            {
                DataSnapshot snapshot = task.Result;

                string playerData = snapshot.GetRawJsonValue();

                foreach (var child in snapshot.Children)
                {
                    string t = child.GetRawJsonValue();

                    GameStatistics extractedData = JsonUtility.FromJson <GameStatistics>(t);

                    LevelPassedList.Add(extractedData.levelPassed);
                }

                //If the level is not passed, hide next levels (buttons).
                int times_passed = countOccurences(LevelPassedList, "yes");
                if (times_passed == 0)
                {
                    levelPassedFlag = false;
                }
                else
                {
                    levelPassedFlag = true;
                }
            }
        })));
    }
Exemplo n.º 12
0
    public Task LoadData_ReturnTask(string level)
    {
        return(databaseReference.Child(usrEmail + "_" + level).GetValueAsync().ContinueWith((task => {
            if (task.IsCanceled)
            {
                Firebase.FirebaseException e = task.Exception.Flatten().InnerExceptions[0] as Firebase.FirebaseException;

                AuthError msg = (AuthError)e.ErrorCode;
                loadError = msg.ToString();
                print("Error: " + loadError);

                return;
            }
            if (task.IsFaulted)
            {
                Firebase.FirebaseException e = task.Exception.Flatten().InnerExceptions[0] as Firebase.FirebaseException;

                AuthError msg = (AuthError)e.ErrorCode;
                loadError = msg.ToString();
                print("Error: " + loadError);

                return;
            }
            if (task.IsCompleted)
            {
                DataSnapshot snapshot = task.Result;

                string playerData = snapshot.GetRawJsonValue();

                foreach (var child in snapshot.Children)
                {
                    string t = child.GetRawJsonValue();

                    GameStatistics extractedData = JsonUtility.FromJson <GameStatistics>(t);


                    AttemptsList.Add(extractedData.gameAttempts);
                    DurationList.Add(extractedData.gameDuration);
                    LevelPassedList.Add(extractedData.levelPassed);
                }


                print("Data loaded successfully!");
                loadSuccessful = true;
            }
        })));
    }
Exemplo n.º 13
0
    void GetErrorMessage(AuthError errorCode)
    {
        string msg = "";

        msg = errorCode.ToString();

        switch (errorCode)
        {
        case AuthError.AccountExistsWithDifferentCredentials:
            break;

        case AuthError.EmailAlreadyInUse:
            break;

        case AuthError.InvalidEmail:
            break;
        }
        print(msg);
    }
Exemplo n.º 14
0
    private async void RegisterUserWithAuthentication(string email, string username, string password, Action <string> OnErrorCallback)
    {
        FirebaseUser user    = null;
        string       message = "Login Failed";
        await DatosFirebaseRTHelper.Instance.auth.CreateUserWithEmailAndPasswordAsync(email, password).ContinueWith(task =>
        {
            if (task.IsFaulted)
            {
                message = "Mail or User Not Available";
            }
            else if (task.IsCompleted)
            {
                if (task.Exception != null)
                {
                    Debug.LogWarning(message: $"failed to register task with {task.Exception}");
                    FirebaseException firebaseEx = task.Exception.GetBaseException() as FirebaseException;
                    AuthError errorCode          = (AuthError)firebaseEx.ErrorCode;
                    switch (errorCode)
                    {
                    case AuthError.EmailAlreadyInUse:
                        break;

                    case AuthError.InvalidEmail:
                        message = "Invalid Email";
                        break;

                    case AuthError.WrongPassword:
                        message = "Wrong Password";
                        break;

                    case AuthError.MissingEmail:
                        message = "Missing Email";
                        break;

                    case AuthError.MissingPassword:
                        message = "Missing Password";
                        break;

                    case AuthError.UserNotFound:
                        message = "Account does not exist";
                        break;

                    default:
                        message = "Error Code " + errorCode.ToString();
                        break;
                    }
                }
                else
                {
                    user = task.Result;
                    if (user != null)
                    {
                        UpdateUserProfile(user);
                    }
                }
            }
        });

        if (user == null)
        {
            OnErrorCallback?.Invoke(message);
        }
    }
Exemplo n.º 15
0
 void GetErrorMessage(AuthError ErrorCode)
 {
     msg = ErrorCode.ToString();
     print(msg);
 }
Exemplo n.º 16
0
    private async Task <FirebaseUser> LoginUserWithAuthentication(string email, string password, Action <string> OnErrorCallback)
    {
        FirebaseUser user    = null;
        string       message = "Login Failed";
        await DatosFirebaseRTHelper.Instance.auth.SignInWithEmailAndPasswordAsync(email, password).ContinueWith(task =>
        {
            if (task.IsFaulted)
            {
                message = "Mail or Pass Invalid";
            }
            else if (task.IsCompleted)
            {
                if (task.Exception != null)
                {
                    Debug.LogWarning(message: $"failed to register task with {task.Exception}");
                    FirebaseException firebaseEx = task.Exception.GetBaseException() as FirebaseException;
                    AuthError errorCode          = (AuthError)firebaseEx.ErrorCode;

                    switch (errorCode)
                    {
                    case AuthError.EmailAlreadyInUse:
                        break;

                    case AuthError.InvalidEmail:
                        message = "Invalid Email";
                        break;

                    case AuthError.WrongPassword:
                        message = "Wrong Password";
                        break;

                    case AuthError.MissingEmail:
                        message = "Missing Email";
                        break;

                    case AuthError.MissingPassword:
                        message = "Missing Password";
                        break;

                    case AuthError.UserNotFound:
                        message = "Account does not exist";
                        break;

                    default:
                        message = errorCode.ToString();
                        break;
                    }
                }
                else
                {
                    user = task.Result;
                    Debug.LogFormat("User signed in succesfully: {0} ({1})", user.DisplayName, user.Email);
                    Debug.Log("Logged IN");
                }
            }
        });

        if (user == null)
        {
            OnErrorCallback?.Invoke(message);
        }

        return(user);
    }