The question is asked already here, but since AngularFire updates their API, the provided solution is not usable anymore.
What I am doing is to create new user's account with email/password, store that user in Firebase Authentication service, and store extra information in the database.
However, in the Authentication, user has their key as simplelogin:29
, and in the Data, each user has their hashed key, as -JpwB9oUVkeT_XRdiX2V
. I do need their keys to be the same.
Below is the code to create new user, registered with auth.$createUser and store extra information in the user model.
var ref = new Firebase('https://myapp.firebaseio.com/');
var auth = $firebaseAuth(ref);
auth.$createUser({
email: user.email,
password: user.password
}).then(function(regUser) {
var ref = new Firebase('https://myapp.firebaseio.com/users/')
var firebaseUser = $firebaseArray(ref);
var userInfo = {
key : regUser.uid, // ex: simplelogin:29
date : Firebase.ServerValue.TIMESTAMP,
firstname : user.firstname,
lastname : user.lastname,
email : user.email,
}; // user info
firebaseUser.$add(userInfo);
});
It works, but not the way supposed to be, as a user's key in Authentication and Data are still different.