From 78d1e3b966c9b6f6e01aefb1a7ba15457df25f21 Mon Sep 17 00:00:00 2001 From: Rand McKinney Date: Tue, 3 Jun 2014 15:14:46 -0700 Subject: [PATCH] Undo incorrect changes I made -- per Ritchie --- docs/api-model-remote.md | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) 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) {