TypeError: Cannot read property 'authenticate' of null TypeError: Cannot read property 'authenticate' of null mongoose mongoose

TypeError: Cannot read property 'authenticate' of null


In controllers/auth.js

Replace the if(err) with if(err || !user) in the findOne() method