Skip to content

Instantly share code, notes, and snippets.

@ebourmalo
Created June 29, 2015 16:17
Show Gist options
  • Save ebourmalo/d3c5f776c8894a343f48 to your computer and use it in GitHub Desktop.
Save ebourmalo/d3c5f776c8894a343f48 to your computer and use it in GitHub Desktop.
// Handle specific permissions
app.service(resourcePath)
.before({
update: handleUpdatePermissions
});
/**
* Handle permissions when updating a project
*
* @param hook {Object} -
* @param next {Function} -
*/
function handleUpdatePermissions (hook, next) {
var user = hook.params.user;
var projectId = hook.id;
return next(new Error('Just for test'));
/* propagate and crash the server with an error 500 response
for the client. How to handle that knowing I don't have access
to the generated rest route for the update (PUT) */
}
@ekryski
Copy link

ekryski commented Jul 5, 2015

Well, we sort of support this with feathers-associations but after starting down that road we realized that you don't even actually need routes like that. You could just call /api/users/2. No need to complicate it by adding more params to your route.

Think about it, when you are calling /api/groups/123/users/2 you already have the user ID. This has come up quite a few times so we are going to be addressing it much more clearly in the documentation in the next release.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment