Undo incorrect changes I made -- per Ritchie
This commit is contained in:
parent
87c9672362
commit
78d1e3b966
|
@ -126,16 +126,16 @@ Run a function before or after a remote method is called by a client.
|
||||||
|
|
||||||
```js
|
```js
|
||||||
// *.save === prototype.save
|
// *.save === prototype.save
|
||||||
User.beforeRemote('*.save', function(ctx, next) {
|
User.beforeRemote('*.save', function(ctx, user, next) {
|
||||||
if(ctx.user) {
|
if(ctx.req.accessToken) {
|
||||||
next();
|
next();
|
||||||
} else {
|
} else {
|
||||||
next(new Error('must be logged in to update'))
|
next(new Error('must be logged in to update'))
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
User.afterRemote('*.save', function(ctx, next) {
|
User.afterRemote('*.save', function(ctx, user, next) {
|
||||||
console.log('user has been saved', ctx.user);
|
console.log('user has been saved', user);
|
||||||
next();
|
next();
|
||||||
});
|
});
|
||||||
```
|
```
|
||||||
|
@ -144,7 +144,7 @@ Remote hooks also support wildcards. Run a function before any remote method is
|
||||||
|
|
||||||
```js
|
```js
|
||||||
// ** will match both prototype.* and *.*
|
// ** 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
|
console.log(ctx.methodString, 'was invoked remotely'); // users.prototype.save was invoked remotely
|
||||||
next();
|
next();
|
||||||
});
|
});
|
||||||
|
@ -160,7 +160,7 @@ User.beforeRemote('*', ...);
|
||||||
User.beforeRemote('prototype.*', ...);
|
User.beforeRemote('prototype.*', ...);
|
||||||
|
|
||||||
// prevent password hashes from being sent to clients
|
// prevent password hashes from being sent to clients
|
||||||
User.afterRemote('**', function (ctx, next) {
|
User.afterRemote('**', function (ctx, user, next) {
|
||||||
if(ctx.result) {
|
if(ctx.result) {
|
||||||
if(Array.isArray(ctx.result)) {
|
if(Array.isArray(ctx.result)) {
|
||||||
ctx.result.forEach(function (result) {
|
ctx.result.forEach(function (result) {
|
||||||
|
|
Loading…
Reference in New Issue