How can i access the details of the user who raise the request from a Model Hook
Comment.beforeSave = function(next,com) {
//Want to add 2 more properties
The beforeRemote hooks execute before the model hooks, so you can add the userId to the request body.
Comment.beforeRemote('**', function (ctx, unused, next) {
var userId = ctx.req.accessToken.userId;
if (ctx.methodString == 'Comment.create' || ctx.methodString == 'Comment.updateAttributes') {
ctx.req.body.userId = userId;
}
next();
});
you might want to review which methodstring suit you best.