我从laravel背景想在我sails.js的应用程序来实现passport.js authentication
与node.js的Passport.js认证
的文件是最小的,也很难理解
这里是我的login.js
module.exports = {
/*
*Normal login
*/
login:function (req,res) {
//user input
console.log('email'+req.parm('email')+'password'+req.param('password'))
passport.authenticate(
'local-login',
function (req,res) {
}
}
passport.use('local-login',new LocalStrategy(function (username,password,done) {
if(username=='test')
return done(null,username);
else
return done(null,false,{message:'Invalid userinfo'})
}));
但passport.authenticate
从来没有发射
从他们做cumentation
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);
});
也是这个又是什么If this function gets called, authentication was successful.
发现这个教程http://iliketomatoes.com/implement-passport-js-authentication-with-sails-js-0-10-2/但其解释如此之差