这是我的ExpressJS控制器:
exports.authenticate = function(req, res) {
Company.findOne({_id: user.company_id}, function(err, company) {
if(err) {
response = {
status: 'error',
error: err
}
} else if(!company) {
response = {
status: 'error',
error: 'User not identified with a company'
}
} else {
req.session = user;
response = {
status: 'ok',
user: user,
api_key: company.api_key
}
return res.json(response);
}
});
}
}
在我的快速配置中,我有:
app.use(express.session({
secret: config.sessionSecret,
store: new mongoStore({
db: db.connection.db,
collection: config.sessionCollection
})
}));
我得到的错误是:TypeError: Object #<Object> has no method 'resetMaxAge'
答案 0 :(得分:1)
尝试将快速配置更改为:
app.use(express.session({
"secret" : config.sessionSecret,
key: 'PutYourKey',
cookie: {secure: false, maxAge: 300000},
store: new mongoStore
({
db: db.connection.db,
collection: config.sessionCollection
})
}));
答案 1 :(得分:0)
虽然这是很久以前我会猜测req.session = user;
是问题的真正根源......