简体   繁体   English

验证用户的电子邮件和密码错误

[英]Authenticating Users with Email & Password error

Im trying to create a mail and password user to firebase, but im kepp getting this error: 我正在尝试为Firebase创建一个邮件和密码用户,但是我却无法得到此错误:

Error: The browser redirected the page before the login request could complete. 错误:浏览器在完成登录请求之前已重定向页面。 {code: "REQUEST_INTERRUPTED", stack: (...), message: "The browser redirected the page before the login request could complete."} {代码:“ REQUEST_INTERRUPTED”,堆栈:(...),消息:“浏览器在完成登录请求之前已重定向页面。”}

var ref = new Firebase("https://***.firebaseio.com");
$('.btn').click(function() {
   var mail = $('#inputEmail3').val();
   var pass = $('#inputPassword3').val();
   ref.createUser({
       email : mail,
       password : pass
    }, function(error) {
       if (error === null) {
        console.log("User created successfully");
       } else {
        console.log("Error creating user:", error);
       }
   });
});

$(document).ready();

If the element you are selecting with the $('.btn') selector is a link the browser will navigate to the linked page before the asynchronous ref.createUser function completes. 如果使用$('.btn')选择器选择的元素是链接,则浏览器将在异步ref.createUser函数完成之前导航到链接页面。 To prevent this, add a return false statement to the end of the click event handler. 为防止这种情况,请在click事件处理程序的末尾添加return false语句。 You can also add an e.preventDefault() statement at the top of the click handler which will ensure that the link navigation does not occur as shown below. 您还可以在点击处理程序的顶部添加e.preventDefault()语句,以确保链接导航不会发生,如下所示。

$('.btn').click(function(e) { //Add the 'e' event object to the parameters
    e.preventDefault() //Prevents navigation (the default link click action)
    var mail = $('#inputEmail3').val();
    var pass = $('#inputPassword3').val();
    ref.createUser({
        email : mail,
        password : pass
    }, function(error) {
       if (error === null) {
        console.log("User created successfully");
       } else {
        console.log("Error creating user:", error);
       }
   });
   return false; //Extra insurance
});

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM