afterCreate
我想在模型回调中获取当前登录用户。在控制器中,从请求标头中找到当前登录的用户 - req.user
。但是在模型的生命周期回调中,会话标头没有被传递。有没有办法从模型中找到当前用户?
我想要这样的东西:
afterCreate: function(record,next){
var currentUser=this.req.user.id; //want to get the request header here with logged in user
AnotherModel.create({something:record.something, createdBy:currentUser}).exec(function(err, anotherRecord){
next()
});
}