expressjs passport登录错误

expressjs passport登录错误,express,passport.js,Express,Passport.js,我尝试用expressjs使用passport。passport.authenticate函数中的req.login函数触发了一个错误,我真的不知道我做错了什么 passport.use(new LocalStrategy({ usernameField: 'email' }, function (username, password, done) { userModel.findOne({ 'email': username }, function (err, user) {

我尝试用expressjs使用passport。passport.authenticate函数中的req.login函数触发了一个错误,我真的不知道我做错了什么

passport.use(new LocalStrategy({ usernameField: 'email' }, function (username, password, done) {

    userModel.findOne({ 'email': username }, function (err, user) {
        if (err) { return done(err); }
        if (!user) { return done(null, false, { message: 'Unknown email adress ' + username }); }
        user.comparePassword(password, function (err, isMatch) {
            if (err) return done(err);
            if (isMatch) {
                return done(null, user);
            } else {
                return done(null, false, { message: 'Invalid password' });
            }
        });
    });
}));

passport.authenticate('local', function (err, user, info) {
            if (err) {
                return res.send(401, "Invalid authentication");
            }

            if (!user) {
                return res.send(401, info.message);
            }

            req.login(user, function (err) {
                //console.log(user);
                console.log(err);
                if (err) {
                    return res.send(401, "Invalid authentication4");
                }
                return res.send(200, res);
            });
        })(req, res, next);  

浏览器向我显示警报无效身份验证4,错误在req.login函数中触发。在shell console.logerr上,谁向我发送了一条未定义的消息[TypeError:Converting circular structure to JSON]

触发响应的错误是什么?未定义的[TypeError:Converting circular structure to JSON]尝试console.logerr.stack以获取堆栈跟踪,这可能会为您提供引发错误的线索。get-TypeError:无法读取undefinedBah的属性“stack”,请尝试console.trace而不是console.log。。。。