passport’s req.isAuthenticated always returning false, even when I hardcode done(null, true)

I had a similar issue. Could be due to the express-session middleware needed for passport. Fixed it by using middlewares in the following order: (Express 4) var session = require(‘express-session’); // required for passport session app.use(session({ secret: ‘secrettexthere’, saveUninitialized: true, resave: true, // using store session on MongoDB using express-session + connect store: new MongoStore({ … Read more

Sending back a JSON response when failing Passport.js authentication

I had a similar issue with Passport and failed login responses. I was building an API, and wanted all responses to be returned as JSON. Passport responds to an invalid password with status: 401 and body: Unauthorized. That’s just a text string in the body, not JSON, so it broke my client which expected all … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)