使用sequelizejs的Passportjs和Postgres TypeError

时间:2015-06-28 20:42:18

标签: postgresql passport.js sequelize.js

我正在尝试使用passportjs / sequelize进行身份验证,但在此处继续获取typeError:

TypeError: undefined is not a function
   at module.exports.getUser (/Users/ra/Desktop/jb/controllers/users.js:44:12)
   at Layer.handle [as handle_request] (/Users/ra/Desktop/jb/node_modules/express/lib/router/layer.js:95:5)
   at next (/Users/ra/Desktop/jb/node_modules/express/lib/router/route.js:131:13)
   at Route.dispatch (/Users/ra/Desktop/jb/node_modules/express/lib/router/route.js:112:3)
   at Layer.handle [as handle_request] (/Users/ra/Desktop/jb/node_modules/express/lib/router/layer.js:95:5)
   at /Users/ra/Desktop/jb/node_modules/express/lib/router/index.js:277:22
   at param (/Users/ra/Desktop/jb/node_modules/express/lib/router/index.js:349:14)
   at param (/Users/ra/Desktop/jb/node_modules/express/lib/router/index.js:365:14)
   at Function.process_params (/Users/ra/Desktop/jb/node_modules/express/lib/router/index.js:410:3)
   at next (/Users/ra/Desktop/jb/node_modules/express/lib/router/index.js:271:10)
   at Function.handle (/Users/ra/Desktop/jb/node_modules/express/lib/router/index.js:176:3)
   at router (/Users/ra/Desktop/jb/node_modules/express/lib/router/index.js:46:12)
   at Layer.handle [as handle_request] (/Users/raDesktop/jb/node_modules/express/lib/router/layer.js:95:5)
   at trim_prefix (/Users/ra/Desktop/jb/node_modules/express/lib/router/index.js:312:13)
   at /Users/ra/Desktop/jb/node_modules/express/lib/router/index.js:280:7
   at Function.process_params (/Users/ra/Desktop/jb/node_modules/express/lib/router/index.js:330:12)

这是控制器的样子:

getUser: function(req, res) {
    User.find({
          where: {
            username: req.params.id,
            displayName: req.user.displayName
          }
        }).success(function(User) {
          res.send(User);
        });
  },

这是身份验证后护照的获取请求

 app.get('/auth/facebook/callback',
    passport.authenticate('facebook', {
      failureRedirect: '/login'
    }),
    function(req, res) {
      console.log(req.user.username)
      res.cookie('signIn', 'true');
      res.redirect('/api/users/' + req.user.username);
    }
  );

0 个答案:

没有答案