I want to get get current logged in user in a models afterCreate
callback. In controller, current logged in user is found form the request header-req.user
. But in model's life-cycle callback the session header is not passed. Is there any way to find the current user from model?
I want something like this:
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()
});
}