node.js - Multiple authentication controllers on one route -


i trying add 2 authentication controllers 1 route. example, trying make:

router.route('/employees')       .get(authcontroller1.isauthenticated, mycontroller1.get1)       .get(authcontroller2.isauthenticated, mycontroller2.get2); 

the isauthenticated function follows:

exports.isauthenticated = passport.authenticate('basic', {   session: false }); 

does know how possible?

thanks, daniel

route:

router.route('/employees')       .get(authcontroller.isauthenticated1, authcontroller.isauthenticated2, mycontroller1.get1) 

authcontroller :

exports.isauthenticated = function(req, res, next) {     // authentication code     if (!req.isauthenticated) {         // not authenticated         return res.status(401).send({             message: 'user not authenticated'         });     }     next(); };  exports.isauthenticated2 = function(req, res, next) {     // authentication2 code     if (!req.isauthenticated2) {         // not authenticated         return res.status(401).send({             message: 'user not authenticated'         });     }     next(); }; 

mycontroller

exports.get1 = function(req, res) {     // both authenticated can proceed. } 

Comments

Popular posts from this blog

Payment information shows nothing in one page checkout page magento -

tcpdump - How to check if server received packet (acknowledged) -