diff --git a/docs/api-model-remote.md b/docs/api-model-remote.md index b2edfecf..3175ddfb 100644 --- a/docs/api-model-remote.md +++ b/docs/api-model-remote.md @@ -126,16 +126,16 @@ Run a function before or after a remote method is called by a client. ```js // *.save === prototype.save -User.beforeRemote('*.save', function(ctx, next) { - if(ctx.user) { +User.beforeRemote('*.save', function(ctx, user, next) { + if(ctx.req.accessToken) { next(); } else { next(new Error('must be logged in to update')) } }); -User.afterRemote('*.save', function(ctx, next) { - console.log('user has been saved', ctx.user); +User.afterRemote('*.save', function(ctx, user, next) { + console.log('user has been saved', user); next(); }); ``` @@ -144,7 +144,7 @@ Remote hooks also support wildcards. Run a function before any remote method is ```js // ** will match both prototype.* and *.* -User.beforeRemote('**', function(ctx, next) { +User.beforeRemote('**', function(ctx, user, next) { console.log(ctx.methodString, 'was invoked remotely'); // users.prototype.save was invoked remotely next(); }); @@ -160,7 +160,7 @@ User.beforeRemote('*', ...); User.beforeRemote('prototype.*', ...); // prevent password hashes from being sent to clients -User.afterRemote('**', function (ctx, next) { +User.afterRemote('**', function (ctx, user, next) { if(ctx.result) { if(Array.isArray(ctx.result)) { ctx.result.forEach(function (result) {