2017-04-05 2 views
0

Meine Webanwendung verwendet Firebase und ich verwende E-Mail/Passwort als Anmeldemethode für meine Anwendung.Ist ist mein Formular innerhalb <form></form> Tag bin ich bekommen auth/Netzwerk-Anfrage-fehlgeschlagen error.Authentication funktioniert gut, wenn ich Form zu Div.
Schritte folgte ich
Schritt 1: Aktiviert Email/Passwort Log-in Verfahren enter image description hereFirebase-Authentifizierung: signInWithEmailAndPassword gibt den Fehlercode auth/network-request-failed zurück

Schritt 2: eine Dummy-Benutzer hinzugefügt enter image description here

Schritt 3: Hier ist Meine Authentifizierungsfunktion

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); 
    }); 
} 

Schritt 4: Anmeldungsformular

<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> 

Bevor Sie die Leute zu fragen überprüfte ich die Firebase Documentation und samples on github und natürlich viel gegoogelt.

Bitte helfen Sie mir.

Antwort

0

es kann durch Authentifizierung Zustand verursacht werden versuchen, manuell Ihre E-Mail und Passwort eingeben und

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

Es tut mir leid, aber was meinen Sie manuell? – shreesha

+0

wie dieses 'signInWithEmailAndPassword ('[email protected] ',' password ')' –

+0

Nein. Es funktioniert nicht – shreesha

Verwandte Themen