title: Automatically login after registration with AngularFire
body: <p>I have an app that allows users to register, login and add content by themselves. 
  For authenticated user, they can visit some pages, otherwise it will direct them to login page. However, I could not figure out how to make the user automatically login (go to a page called tools) after the registration. How can I pass the login information from the registration page to the tools page?</p>
  
  <p>Here is my route for tools page and login page:</p>
  
  <pre><code>.config(['$routeProvider', function($routeProvider) {
  
    $routeProvider
      .when('/tools', {
          templateUrl: 'app/shared/nav.html',
          controller: 'NavCtrl',
          resolve: {
               // controller will not be loaded until $requireAuth resolves
              "currentAuth": ["$firebaseAuth", function ($firebaseAuth) {
                  var firebaseObj = new Firebase("https://scurdangular.firebaseio.com/");
                  var loginObj = $firebaseAuth(firebaseObj);
                  return loginObj.$requireAuth();
              }]
          }
      })
      .otherwise({
          redirectTo: '/login'
      }); 
  }])
  </code></pre>
  
  <p>Here is the registration controller:</p>
  
  <pre><code>// Register controller
  .controller('RegisterCtrl', ['$scope', '$firebaseArray', '$location', 'CommonProp', '$firebaseAuth', function($scope, $firebaseArray, $location, CommonProp, $firebaseAuth) {
  $scope.signUp = function() {
  
      var firebaseObj = new Firebase("https://xxxxxx.firebaseio.com/");
      var auth = $firebaseAuth(firebaseObj);
      var loginObj = $firebaseAuth(firebaseObj);
  
      var email = $scope.user.username +'@whateverdomain.com';
      var password = $scope.user.password;
  
      // Sign up implementation 
      if (!$scope.regForm.$invalid) {
          console.log('Valid form submission');
  
          auth.$createUser({email, password})
                 .then(function(userData) {
  
                      // login user after registration
  
                      loginObj.$authWithPassword({
                              email: email,
                              password: password
                       });
                       $location.path('/tools');
                       console.log('user creation success', userData.uid);
                              }, function(error) {
                                  console.log(error);
                                  $scope.regError = true;
                                  $scope.regErrorMessage = error.message;
                              });
  
                      }
  
              });
          });
      }    
  };}])
  </code></pre>