Skip to content
This repository has been archived by the owner on Dec 8, 2022. It is now read-only.

Add an error message when id is null #10

Merged
merged 1 commit into from
Apr 14, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/restrict-to-roles.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,10 @@ export default function (options = {}) {
// If we should allow users that own the resource and they don't already have
// the permitted roles check to see if they are the owner of the requested resource
if (options.owner && !authorized) {
if (hook.id === null) {
throw new errors.BadRequest('Can not verify roles when changing many resources.');
}

if (!hook.id) {
throw new errors.MethodNotAllowed(`The 'restrictToRoles' hook should only be used on the 'get', 'update', 'patch' and 'remove' service methods if you are using the 'owner' field.`);
}
Expand Down