title: Passportjs: Cannot read property 'connection' of undefined at Strategy._verify
body: <p>Using passportjs for authentication in my node.js application but getting the error above. This is my code below</p>
  
  <p><strong>app.js</strong> </p>
  
  <pre><code>passport.use(new LocalStrategy({usernameField: 'email'},function(email, password, res, done) {
      res.locals.connection.query('SELECT id, password FROM users WHERE email = ?', [email], function(err, user) {
          console.log(user);
  
          if (err) {return done(err)};
  
          if (user.length === 0) {
              done(null, false);
          };
  
          const hash = user[0].password.toString();
          console.log(hash);
  
          bcrypt.compare(password, hash, function(err, res) {
              if (res === true) {
                  return done(null, {user_id: user[0].id});
              } else {
                  return done(null, false);
              }
          });
      });
  }
  ));
  </code></pre>
  
  <p><strong>index.js</strong></p>
  
  <pre><code>router.post('/', passport.authenticate('local', {
      successRedirect: 'home',
      failureRedirect: '/'
  }));
  </code></pre>
  
  <p>What could be wrong with my code?</p>