I am working on a project, and I need to authenticate users through JWT, I created a route middleware for each type of users like admins, users, customers and so on.
router
.route('/customers')
.get(ctrlCustomers.authenticate, ctrlCustomers.getFunction);
Now, If some API in the customers part and I need to allow to both customers and admins to it, so that when the customer requests it works and when admin requests it should also work. How can I make this? What I need to do is most probably like this:
router
.route('/customers')
.get(ctrlAdmins.authenticate | ctrlCustomers.authenticate, ctrlCustomers.getFunction);
How to add an OR-like operation inside the middleware route, and anyone returns the next();
function should authenticate and neglect the other one.