错误:未知的身份验证策略“ jwt”

时间:2018-08-16 04:42:45

标签: node.js express authentication jwt passport.js

我正在学习abt护照和jwt身份验证,但我遇到一个错误,说Error: Unknown authentication strategy "jwt"

这是我的auth.js

const passport = require('passport')

module.exports = function(req, res, next){
    passport.authenticate('jwt', function (err, user){
        if (err || !user){
            res.status(403).send({
            error: "you dont have access to this resource"                
            })
        }else{
            req.user = user
            next()
        }
    })(req, res, next)
}

谁能发现哪个错误?谢谢

0 个答案:

没有答案