【发布时间】:2023-04-05 16:43:01
【问题描述】:
我来自 laravel 背景,试图在我的sails.js 应用程序中实现passport.js authentication
文档很少,也很难理解
这是我的 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 从未被解雇
来自他们的文档
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/,但是它的解释太差了
【问题讨论】:
标签: javascript node.js sails.js passport.js