我试图实现firebase的简单登录(电子邮件/密码)。我在硬编码时工作的代码,但我不能让它拿起输入并登录到firebase。它没有给我任何错误,它只是没有在我的firebase中创建用户。任何提示?
我的代码:http://jsfiddle.net/Ygs3E/2/
var myRootRef = new Firebase('https://crowdfluttr.firebaseio.com/');
var auth = new FirebaseSimpleLogin(myRootRef, function (user) {
});
$("#registerUser").on("click", function() {
auth.createUser("email", "password", function () {})
})
<form>
Email: <input type="text" id="email" name="email"><br>
Password: <input type="password" id="password" name="password"><br>
<input id="registerUser" type="submit" value="Register">
</form>
答案 0 :(得分:3)
Firebase简单登录只是一个身份验证服务器,它不会将任何信息存储到您的Firebase中。您可以轻松地在createUser
函数内部执行此操作。
var email = // get email textbox value
var pass = // get password textbox value
$("#registerUser").on("click", function() {
auth.createUser(email, pass, function (error, user) {
// if there's no error save the user to the users location
// and use the uid as the key to store the user
if(!error) {
myRootRef.child("users").child(user.uid).set(user);
}
});
});
关于加藤的评论。这只会创建一个不登录的用户。
答案 1 :(得分:0)
当我开始使用Firebase的Password
身份验证服务时,我遇到了类似的问题。除了有关帐户创建和用户信息存储的所有先前答案之外,请确保Enable Email & Password Authentication
Enable Email & Password Authentication
选项有关其他信息,请查看Firebase User Authentication页。