title: Express Passport.js Success redirect doesn't load page, request keeps pending
body: <p>I am trying to do a basic username/password authentication using passport.js and passport local.</p>
  
  <p>While <code>failureRedirect</code> does exactly what it is supposed to do, (redirects to a specified page), <code>successRedirect</code> keeps pending with the request for its specified page, and after some time, it returns <code>empty response</code>.</p>
  
  <p><a href="http://www.deviantpics.com/VdG" rel="nofollow noreferrer">http://www.deviantpics.com/VdG</a></p>
  
  <p>As you can see in this picture, when it is requesting dashboard, it says that its size is <code>0B</code>, but when I go on that dashboard without redirecting it says it has <code>1.6B</code>.</p>
  
  <p>I have looked all over Stackoverflow, and I couldn't find an answer that would help me.</p>
  
  <p>Could you please check my code and suggest something before I go berserk?</p>
  
  <p>This is passport load code</p>
  
  <pre><code>//set expression
  var expressSession = require('express-session');
  app.use(expressSession({
      secret: credentials.session.secret
  }));
  
  //set passport
  var passport = require('passport');
  
  var localStrategy = require('./strategies/auth/local.js');
  passport.use('local', localStrategy);
  
  passport.serializeUser(function(user, done) {
      done(null, user.id);
  });
  
  passport.deserializeUser(function(id, done) {
      User.findById(id, function(err, user) {
          done(err, user);
      });
  });
  
  app.use(passport.initialize());
  app.use(passport.session());
  </code></pre>
  
  <p>routes.js</p>
  
  <pre><code>module.exports = function(app) {
  
  //main
  app.get('/', main.home);
  app.get('/login', main.login);
  app.get('/signup', main.signup);
  app.post('/login', auth.loginLocal);
  app.post('/signup', main.checkSignup);
  
  //user
  app.get('/user/dashboard', user.dashboard);
  app.get('/user/addmemory', user.addMemory);
  app.get('/user/memory', user.memory);
  </code></pre>
  
  <p>login function </p>
  
  <pre><code>exports.loginLocal = passport.authenticate('local', {
      successRedirect: '/user/dashboard',
      failureRedirect: '/login'
  });
  </code></pre>
  
  <p>local strategy</p>
  
  <pre><code>var localAuthStrategy = new LocalStrategy(function(username, password, done) {
  
      User.findOne({
          username: username
      }, function(err, user) {
          if (err) {
              return done(err);
          }
  
          if (!user) {
              return done(null, false, {
                  message: 'Incorrect username'
              });
          }
  
          if (!user.validPassword(password)) {
              return done(null, false, {
                  message: 'Incorrect password'
              });
          }
  
          return done(null, user);
      });
  
  
  });
  </code></pre>
  
  <p>dashboard function</p>
  
  <pre><code>exports.dashboard = function(req, res) {
      res.render('user/dashboard', {
          layout: 'user'
      });
  };
  </code></pre>