Skip to content

Instantly share code, notes, and snippets.

@microbial
Created January 11, 2016 21:06
Show Gist options
  • Save microbial/f52f6fa6720758b7bf8e to your computer and use it in GitHub Desktop.
Save microbial/f52f6fa6720758b7bf8e to your computer and use it in GitHub Desktop.
Make user node in firebase
//Assuming you're already in an angular controller...
$scope.user = {};
//$scope.user will get filled with "email" and "password" keys
var enteredUsername = angular.copy($scope.username);
$scope.register = function() {
var ref = new Firebase("https://<YOUR-FIREBASE-APP>.firebaseio.com");
var user = angular.copy($scope.user);
ref.createUser({
email : user.email,
password : user.password
}, function(error, userData) {
if (error) {
console.log("Error creating user:", error);
} else {
console.log("Successfully created user account with uid:", userData.uid);
ref.child('users').child(userData.uid).set({
username: enteredUsername
});
}
});
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment