title: I can't get passport remember me working with express router
body: <p>I'm using passport remember me with express router. It's not working properly when I use:</p>
  <pre><code>router.route(&quot;/login).(someController().postlogin)
  </code></pre>
  <p>Then the authentication is not working as it doesn't generate the token.</p>
  <p>But when I use the <code>app.post</code> then it's working.</p>
  <p>Working code:</p>
  <pre><code>  app.post('/login',  passport.authenticate('local', { failureRedirect: '/login' }),async function(req, res, next) {
      // issue a remember me cookie if the option was checked
      if (!req.body.remember_me) { return next(); }
  
      var token = utils.randomString(64);
      try {
          const tokenData= await Token.create({ userId: req.user.id, token });
          res.cookie('remember_me', token, { path: '/', httpOnly: true, maxAge: 604800000 }); // 7 days
        return next();
      } catch (error) {
          return next();  
      }
    },
    function(req, res) {
      res.redirect('/');
    });
  </code></pre>
  <p>But when I use the same code with router it's not working:</p>
  <pre><code>        postLogin: (req, res) =&gt; {
               passport.authenticate('local', { failureRedirect: '/login' }),async function(req, res, next) {
      // issue a remember me cookie if the option was checked
      if (!req.body.remember_me) { return next(); }
  
      var token = utils.randomString(64);
      try {
          const tokenData= await Token.create({ userId: req.user.id, token });
          res.cookie('remember_me', token, { path: '/', httpOnly: true, maxAge: 604800000 }); // 7 days
        return next();
      } catch (error) {
          return next();  
      }
    },
    function(req, res) {
      res.redirect('/');
    }
                 
      
          },
     
  </code></pre>
  <p>I am using:</p>
  <ul>
  <li><a href="http://www.passportjs.org/packages/passport-remember-me/" rel="nofollow noreferrer">http://www.passportjs.org/packages/passport-remember-me/</a></li>
  <li><a href="http://www.passportjs.org/" rel="nofollow noreferrer">http://www.passportjs.org/</a></li>
  </ul>