blob: daeda6850c79fa07b1a4a1bf97864cfcaafd4550 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
|
const { hooks } = require ('@feathersjs/authentication-local');
const { NotAuthenticated } = require('@feathersjs/errors');
const compareUser = async context => {
if (context.id !== context.params.user._id.toString()) {
throw new NotAuthenticated('You can only PATCH/UPDATE your own user!');
}
return context;
};
module.exports = {
after: {
all: hooks.protect('password')
},
before: {
patch: [compareUser],
update: [compareUser]
}
};
|