title: Passport.js Ajax login?
body: <p>Is it possible to login via ajax with passport.js? </p>
  
  <p>The thing is i'm creating a user via ajax and i want it to be logged in automatically (everything with json in a restful style) but the req.login() does some stuff that i don't know and that apparently sends its own status, headers and even it redirects to the home but and i need is to create my own json response.</p>
  
  <p>The code where i create the user:</p>
  
  <p>signup_facebook: function (req, res) {</p>
  
  <pre><code>    var restponse = new Restponse();
  
      var body = req.body;
  
      var obj = {
          display_name: body.first_name,
          name: body.first_name,
          surname: body.last_name,
          photos: ['http://graph.facebook.com/'+ body.id+ '/picture?type=normal'],
          gender: body.gender,
          facebook: {
              userID: body.id,
              displayName: body.display_name
          }
      }
  
      User.facebookSignUp(obj, function(user){
  
          if(user !== false){
              user = obj;
              restponse.location = '/';
              restponse.status = HTTPStatus.REST.C201_OK;
          }else{
              restponse.location = '/';
              restponse.status = HTTPStatus.REST.C302_FOUND;
          }
  
          restponse.body = user;
  
          req.login(user, {}, function(err) {
              APIheart.respondJson(res, restponse);
          });
      })
  </code></pre>
  
  <p>Thanks for your time!</p>