我正在尝试使用Firebase通过电子邮件/密码注册来构建基本Web应用程序,并提供用户身份验证。通过Firebase登录电子邮件/密码
我的设置,现在包括由以下的main.js文件:从形式和登录
var dbRef = new Firebase('https://url.firebaseIO.com');
var authClient = new FirebaseAuthClient(dbRef, function(error, user) {
if (error) {
// an error occurred while attempting login
console.log(error);
} else if (user) {
// user authenticated with Firebase
console.log('User ID: ' + user.id + ', Provider: ' + user.provider);
} else {
// user is logged out
console.log('logged out!');
}
});
function next(){
window.location = 'index.html';
}
function test(){
authClient.login('password', {
email: email,
password: password,
rememberMe: true
},next());
// window.location = 'index.html';
}
我获得电子邮件/密码值。这样可行。但只要我包含一个回调函数,然后将它们重定向到一个新的认证页面,它就不再起作用。实际上,大部分时间我都会收到“UNKOWN ERROR”(未知错误)响应。当我到达下一页时,我不再登录。如果我删除next()函数并保持在同一页面上,它将起作用 - 即使我然后从控制台触发下一个函数。您是否有其他方式进入另一页?
我很确定存在某种通信问题(可能登录在页面切换之前没有得到返回?),因为如果我在下一个函数之前添加1s超时,它将起作用。但是,这肯定不是最佳做法?
谢谢!