Firebase Web身份验证:电子邮件地址格式错误

时间:2018-07-09 07:27:39

标签: javascript firebase firebase-authentication

我正在尝试使用Firebase身份验证创建一个简单的Web身份验证页面,但每次都会收到此错误

//HTML: 

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Document</title>
    <script src="https://www.gstatic.com/firebasejs/5.2.0/firebase.js"></script>
</head>
<body>
    <label>Email</label>
    <input type="email" id="txtEmail"><br/>
    <br/>
    <label>Password</label>
    <input type="password" id="txtPass"><br/><br/>
    <button id="loginButton" onclick="validate();">Login</button>
    <script src="auth2.js"></script>
</body>
</html>

// JS文件

// Initialize Firebase
  var config = {
    apiKey: "YOUR_API_KEY",
    authDomain: "YOUR_DOMAIN",
    databaseURL: "YOUR_DB_URL",
    projectId: "PROJECT_ID",
    storageBucket: "STORAGE",
    messagingSenderId: "SENDER_ID"
  };
  firebase.initializeApp(config);

    var email = document.getElementById("txtEmail").value;
    var pass = document.getElementById("txtPass").value;


    function validate(){
        const auth = firebase.auth();
        const promise = auth.signInWithEmailAndPassword(email, pass);
        promise.catch(function(error){
            console.log("Got a error", error);
        })
    }

我在控制台中收到此错误:

Fr {code: "auth/invalid-email", message: "The email address is badly formatted."}

0 个答案:

没有答案