我從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/但其解釋如此之差