Search code examples
javascriptfirebasefirebasesimplelogin

Firebase Simple Login - new emails not registering to firebase


im trying to implement firebase's simple login (email/password). the code i have works when hard coded but i cannot get it to pick up the inputs and log to firebase. its not giving me any errors, its simply not creating the user in my firebase. any tips?

my code: 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>

Solution

  • Firebase Simple Login is just an authentication server, it doesn't store any information into your Firebase. You can easily do that inside of your createUser function however.

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

    In regards to Kato's comment. This is will only create a user not log one in.