Advertisement
Guest User

Untitled

a guest
Apr 21st, 2016
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.95 KB | None | 0 0
  1. .controller('signupCtrl', function($scope, $firebaseAuth, $firebaseObject, $location) {
  2. var ref = new Firebase("https://plannter.firebaseio.com");
  3. console.log(ref);
  4.  
  5. $scope.authObj = $firebaseAuth(ref);
  6. var obj = $firebaseObject(ref);
  7.  
  8. $scope.addUser = function() {
  9. $scope.authObj.$createUser({
  10. email: $scope.email,
  11. password: $scope.password
  12. }, function(error, userData) {
  13. if (error){
  14. console.log("Error creating user : ", error);
  15. } else {
  16.  
  17. console.log("Succesfully created user : " + userData.uid);
  18. }
  19. }).then(function(userData){
  20.  
  21. return $scope.authObj.$authWithPassword({
  22.  
  23. email: $scope.email,
  24. password: $scope.password
  25. });
  26. }).then(function(authData){
  27.  
  28. console.log("Logged in as: ", authData.uid);
  29. $location.path('/home'); //CHANGE THIS TO DASHBOARD
  30. }).catch(function(error){
  31. console.error("Error : ", error);
  32. })
  33.  
  34.  
  35.  
  36. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement