Created
January 11, 2016 21:06
-
-
Save microbial/f52f6fa6720758b7bf8e to your computer and use it in GitHub Desktop.
Make user node in firebase
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//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