From 8e05164678d302700c794feecd50d83357f7719d Mon Sep 17 00:00:00 2001 From: Jules Laplace Date: Thu, 16 Mar 2017 15:50:10 +0100 Subject: feathers stuff --- src/hooks/index.js | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 src/hooks/index.js (limited to 'src/hooks') diff --git a/src/hooks/index.js b/src/hooks/index.js new file mode 100644 index 0000000..2b122bb --- /dev/null +++ b/src/hooks/index.js @@ -0,0 +1,19 @@ +'use strict'; + +// Add any common hooks you want to share across services in here. +// +// Below is an example of how a hook is written and exported. Please +// see http://docs.feathersjs.com/hooks/readme.html for more details +// on hooks. + +const hooks = require('feathers-hooks'); +const auth = require('feathers-authentication').hooks; +const or = require('promise-or'); + +exports.restrictToOwnersOrAdmins = function() { + var ownerHook = auth.restrictToOwner() + var adminHook = auth.restrictToRoles({ roles: ["admin"] }) + return function(hook) { + return or(ownerHook(hook), adminHook(hook)) + }; +}; -- cgit v1.2.3-70-g09d2