我对facebook和linkedin回调有以下回调:
router.get('/auth/linkedin/callback', social.linkedin().authenticate('linkedin', {failureRedirect: '/web/login'}), function(req, res, next) { res.redirect(req.session.redirectURL); });
router.get('/auth/facebook/callback', social.facebook().authenticate('facebook', {failureRedirect: '/web/login'}), function(req, res, next) { res.redirect(req.session.redirectURL); });
如何对它们进行参数化以便我可以取消一个衬垫,比如说
// somehow get a service from the wildcard in the uri
router.get('/auth/*/callback', social.service().authenticate(service, {failureRedirect: '/web/login'}), function(req, res, next) { res.redirect(req.session.redirectURL); });
答案 0 :(得分:0)
试试这个
router.get('/auth/:service/callback', function (req, res, next) {
social[req.params.service]().authenticate(req.params.service, {failureRedirect : '/web/login'})(req, res, next);
}, function (req, res, next) {
res.redirect(req.session.redirectURL);
});