没有使用passport.initialize()中间件

时间:2019-05-27 11:32:59

标签: node.js

我正在通过调用登录API来在Node.js应用程序中实现本地护照信息

passport.initialize() middleware not in use
    at IncomingMessage.req.login.req.logIn (/home/iffi/Desktop/Node/attendence-server-app/node_modules/passport/lib/http/request.js:46:34)
    at Strategy.strategy.success (/home/iffi/Desktop/Node/attendence-server-app/node_modules/passport/lib/middleware/authenticate.js:248:13)

我的passport.js文件是这样的:

passport.use('local', new LocalStrategy({ passReqToCallback: true },
        function (req, username, password, done) {

           var rows = [{username:'root'}]
               return done(null, rows[0]);
            });

我正在通过以下代码调用API:

 app.post('/login',function(req,res,next){
                console.log('req.body',req.body)
                next()
            }, passport.authenticate('local'), function (req, res) {

                res.send(req.user);
            });

0 个答案:

没有答案