0

My requirement is i need check valid user name and PASSWORD, if it is correct then get the details of particular user, once data is retrieved i need to navigate another page, Below is code, Please help how to call:

validateFirebase = (email, pass) => {
        firebase
          .auth()
          .signInWithEmailAndPassword("xxxx@gmail.com", "123456")
          .then(user => {
            const { currentUser } = firebase.auth();
            this.setState({ currentUser });
            //alert(currentUser)
            let u_ref = currentUser.uid;
            console.log(u_ref);
            let userEmail = currentUser.email;
            console.log(userEmail);

            firebase
              .database()
              .ref("users_ids/0")
              .once("value")
              .then(function(snapshot) {
                snapshot.forEach(function(childSnapshot) {
                  var key = childSnapshot.key;
                  var childData = childSnapshot.val();
                  if (key == u_ref) {
                    role = childData.role;
                    console.log("hgghgh" + role);
                    this.props.navigation.navigate("driverloginScreen");

                  }
                });
              })
              .catch(function(error) {});
          })
          .catch(function(error) {});


      };
  • Anybody have a solution, please let me know – Indira Maddikunta Dec 18 '18 at 08:00
  • Curious here how you are signing in? because it looks like you are rolling your own auth system and just using one account for firebase auth? why the .signInWithEmailAndPassword("xxxx@gmail.com", "123456") instead of .signInWithEmailAndPassword(email, password?). Normally with auth you would setup a callback when the authentication state changes, firebase.auth().onAuthStateChanged((user) => {check if user is signing in or out and do the navigation.navigate call here}); – Benjamin Scherer Jan 07 '19 at 21:00

0 Answers0