2017-04-05 48 views
0

我的Web應用程序正在使用Firebase,並且我正在使用電子郵件/密碼作爲登錄方法用於我的application.issue,當我的表單處於內部時<form></form>標記我是獲得驗證/網絡請求失敗 error.Authentication正常工作,如果我改變形式爲div。
步驟I,接着
步驟1:啓用電子郵件/密碼登錄方法 enter image description hereFirebase身份驗證:signInWithEmailAndPassword返回錯誤代碼身份驗證/網絡請求失敗

步驟2:添加了虛擬用戶 enter image description here

步驟3:這裏是我的驗證功能

function authenticateUser() { 
    var email = document.getElementById("email").value; 
    var password = document.getElementById("password").value; 

    firebase.auth().signInWithEmailAndPassword(email, password).catch(function (error) { 
     // Handle Errors here. 
     var errorCode = error.code; 
     var errorMessage = error.message; 
     if (errorCode === 'auth/wrong-password') { 
      alert('Wrong password.'); 
     } 
     else if (errorCode = 'auth/network-request-failed') { 
      alert('Network error.'); 
     } else { 
      alert(errorMessage); 
     } 
     console.log(error); 
    }); 
} 

步驟4:我的登錄表單

<form class="form-signin"> 
         <h1>Login to Your Account</h1> 
         <label for="inputEmail" class="sr-only">Email address</label> 
         <input type="email" id="email" class="form-control" placeholder="Email address" required="" autofocus=""> 
         <label for="inputPassword" class="sr-only">Password</label> 
         <input type="password" id="password" class="form-control" placeholder="Password" required=""> 
         <div class="checkbox"> 
          <label><input type="checkbox" value="remember-me"> Remember me</label> 
         </div> 
         <button id="login" class="btn btn-lg btn-primary btn-block" type="submit">Sign in</button> 
        </form> 

之前詢問你的人,我檢查了Firebase Documentationsamples on github和ofcourse一派很多。

請幫幫我。

回答

0

它可以通過驗證狀態引起儘量手動輸入你的電子郵件和密碼,

firebase.auth().signInWithEmailAndPassword(email, password).catch(function(error) { 
    var errorCode = error.code; 
    var errorMessage = error.message; 
    console.error({ ErrorCode: errorCode, ErrorMessage: errorMessage }); 
}); 
+0

我很抱歉,但你是什麼意思手動? – shreesha

+0

像這樣'signInWithEmailAndPassword('[email protected]','password')' –

+0

編號它不起作用 – shreesha