summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/services/user/hooks/index.js18
1 files changed, 15 insertions, 3 deletions
diff --git a/src/services/user/hooks/index.js b/src/services/user/hooks/index.js
index 8210e81..22493c6 100644
--- a/src/services/user/hooks/index.js
+++ b/src/services/user/hooks/index.js
@@ -77,9 +77,17 @@ function removeUserMeals () {
// Set provider as undefined so we avoid an infinite loop if this hook is
// set on the resource we are requesting.
var params = Object.assign({}, hook.params, { provider: undefined });
- return hook.app.service('meals').remove(null, { userid: hook.params.user.id }).then(function (data) {
- resolve(hook);
- }).catch(reject);
+
+ return _this.get(hook.id, params).then(function (data) {
+ if (data.toJSON) {
+ data = data.toJSON();
+ } else if (data.toObject) {
+ data = data.toObject();
+ }
+ return hook.app.service('meals').remove(null, { query: { userid: hook.id }}).then(function (data) {
+ resolve(hook);
+ }).catch(reject);
+ })
});
}
}
@@ -97,6 +105,10 @@ exports.before = {
auth.verifyToken(),
auth.populateUser(),
auth.restrictToAuthenticated(),
+ auth.restrictToRoles({
+ fieldName: 'role',
+ roles: ['manager','admin'],
+ }),
],
get: [
auth.verifyToken(),