hagopj13 / node-express-boilerplate

A boilerplate for building production-ready RESTful APIs using Node.js, Express, and Mongoose
MIT License
6.99k stars 2.05k forks source link

Check If Authenticated In Middleware #233

Closed omerfdmrl closed 1 year ago

omerfdmrl commented 1 year ago

Hi. I want to check if authenticated in new middleware like that;

new-plugin.js

module.exports = async(req, res, next) => {
    if (req.user) { ... }
    next();
};

In app.js I'm using right before then v1 api routes. Auth middleware calling after that middleware. How can I fix that?

alibabayev0 commented 1 year ago

Hi Ömer, please may you describe more detailed? Please, move your question to discussion and do not create question as issue.