Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

javascript firebase.auth().signInWithEmailAndPassword not be able to get success event

I am working with java-script fire-base in my app.

I am able to createUserWithEmailAndPassword successfully in app. Also it is showing that data inside Fire-base Console.

Here is snippet.

firebase.auth().createUserWithEmailAndPassword("[email protected]", "*******").catch(function(error) {
      // Handle Errors here.
      var errorCode = error.code;
      var errorMessage = error.message;
      console.log("Eroor Msg"  + errorMessage);

      // ...
    });

Then I have gone through firebase.auth().signInWithEmailAndPassword.

With above method I am not be able to get any success event or message to log. Even it is not throwing any error.

Here is snippet.

firebase.auth().signInWithEmailAndPassword("[email protected]", "*****")
        .catch(function(error) {
      // Handle Errors here.
      var errorCode = error.code;
      var errorMessage = error.message;
      if (errorCode === 'auth/wrong-password') {
        alert('Wrong password.');
      } else {
        alert(errorMessage);
      }
      console.log(error);
    });

My question is how to get success event in this method signInWithEmailAndPassword ?

Any help will be greatly appreciated.

like image 539
Jay Rathod RJ Avatar asked Nov 16 '16 12:11

Jay Rathod RJ


1 Answers

Just check the below code:

firebase.auth().signInWithEmailAndPassword("[email protected]", "******")
   .then(function(firebaseUser) {
       // Success 
   })
  .catch(function(error) {
       // Error Handling
  });
like image 147
Libu Mathew Avatar answered Oct 08 '22 07:10

Libu Mathew



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!