javascript firebase.auth().signInWithEmailAndPassword无法获得成功事件

Jay*_* RJ 10 javascript firebase firebase-authentication

java-script fire-base在我的应用程序中工作.

我能够createUserWithEmailAndPassword在app中成功.它也在里面显示数据Fire-base Console.

这是片段.

firebase.auth().createUserWithEmailAndPassword("abc@gmail.com", "*******").catch(function(error) {
      // Handle Errors here.
      var errorCode = error.code;
      var errorMessage = error.message;
      console.log("Eroor Msg"  + errorMessage);

      // ...
    });
Run Code Online (Sandbox Code Playgroud)

然后我经历了firebase.auth().signInWithEmailAndPassword.

使用上述方法,我无法获得任何成功事件或消息log.即使它不扔任何东西error.

这是片段.

firebase.auth().signInWithEmailAndPassword("abc@gmail.com", "*****")
        .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);
    });
Run Code Online (Sandbox Code Playgroud)

我的问题是如何在这种方法中获得成功事件signInWithEmailAndPassword

任何帮助将不胜感激.

Lib*_*hew 33

只需查看以下代码:

firebase.auth().signInWithEmailAndPassword("abc@gmail.com", "******")
   .then(function(firebaseUser) {
       // Success 
   })
  .catch(function(error) {
       // Error Handling
  });
Run Code Online (Sandbox Code Playgroud)

  • 谢谢.这在官方文档中没有列出.https://firebase.google.com/docs/reference/js/firebase.auth.Auth#signInWithEmailAndPassword (2认同)