title: Angular communication with back-end
body: <p>I'm trying to create an authentication-service in angular in order to register/login users. </p>
  
  <p>After registering a new user I have some trouble receiving the response to the service.</p>
  
  <p>Here is the flow:</p>
  
  <p>Front-end controller that passes the new user to the Auth-service:</p>
  
  <pre><code>vm.onSubmit = function () {
        Authentication
        .register(vm.credentials)  
          .then(function(){       
            $location.path('/');
          });
      };
  </code></pre>
  
  <p>The Authentication-services <code>register</code>-function</p>
  
  <pre><code>register: function(user) {
            return $http.post('/api/register', user).success(function(data){
            console.log('authserviceDONE'); //I never get back here...
            });
          },
  </code></pre>
  
  <p>The <code>api/register</code> -route</p>
  
  <pre><code>app.post('/api/register', function(req, res) {
          User.register(new User({ username: req.body.username}), req.body.password, function(err,user) {
              if (err) {
                  return res.json(err);
              }
              passport.authenticate('local')(req, res, function () {
                  console.log(req.user); // User gets logged
              return req.user;
          });
  
          });
  });
  </code></pre>
  
  <p>I am hoping to receive the user-object in the front-end in order to log him in to the app but the Auth-service never receives anything. Any tips on what I might be missing here?</p>