title: Prevent user authentication after signup with passport
body: <p>I have set up a login/signup interface and mechanism using passport and express.js. The problem that I have is that after the signup of the user, we are redirected to the login page, but we can eventually change the URL and enter immediately in the user profile, but this is of course not expected and wanted. I would like that the user is not authenticated after the signup and that he needs to enter his/her credentials manually in the login page before entering to its profile.</p>
  
  <pre><code>router.get('/', isAuthenticated, function(req, res) {
  
    res.render('library', {
      // passing the id of and username the connecting user to the dust
      userid: req.user._id,
      username: req.user.userName
    });
  });
  
  router.get('/library', isAuthenticated, function(req, res) {
    res.render('library', {
      // passing the id of and username the connecting user to the dust
      userid: req.user._id,
      username: req.user.userName
    });
  });
  
  /* GET login page. */
  router.get('/login', function(req, res) {
    // Display the Login page with any flash message, if any
    res.render('login', {
      message: req.flash('message')
    });
  });
  
  /* Handle Login POST 
  
  password.authenticate is used to delegate the authentication 
  to the login strategy when a HTTP POST is made to /login.
  */
  router.post('/login', passport.authenticate('login', {
    successRedirect: '/library',
    failureRedirect: '/',
    failureFlash: true
  }));
  
  /* GET Registration Page */
  router.get('/signup', function(req, res) {
    res.render('signup', {
      message: req.flash('message')
    });
  });
  /* Handle Registration POST 
  
  password.authenticate is used to delegate the authentication 
  to the signup strategy when a HTTP POST is made to /signup.
  */
  router.post('/signup', passport.authenticate('signup', {
    successRedirect: '/login',
    failureRedirect: '/signup',
    failureFlash: true
  }));
  </code></pre>
  
  <p>and the <code>isAuthenticated</code> function/middleware is defined as follows</p>
  
  <pre><code>var isAuthenticated = function(req, res, next) {
    // if user is authenticated in the session, call the next() to call the next request handler 
    // Passport adds this method to request object. A middleware is allowed to add properties to
    // request and response objects
    if (req.isAuthenticated()) {
      return next();
    } else {
      res.redirect('/login');
    }
  
  }
  </code></pre>
  
  <p>What am I doing wrong?</p>
  
  <p>Basically, after signup, I have a button which redirects to <code>/</code>, and if we are redirected to <code>library</code>  (like it's happening to me), then the user should already be authenticated, but I don't want this...</p>