【发布时间】:2018-01-08 20:23:54
【问题描述】:
护照本地策略与自定义代码的对比
// passport involved code
app.post('/login',
passport.authenticate('local'),
function(req, res) {
// If this function gets called, authentication was successful.
// `req.user` contains the authenticated user.
res.redirect('/users/' + req.user.username);
});
我也可以调用我的本地函数,它可以检查护照本地策略检查的相同内容,因此为什么要创建本地策略
// custom checking function
app.post('/login',
customfunctionhere,
function(req, res) {
// If this function gets called, authentication was successful.
// `req.user` contains the authenticated user.
res.redirect('/users/' + req.user.username);
});
【问题讨论】:
标签: node.js mongodb express passport.js