Skip to content
This repository was archived by the owner on Jun 27, 2019. It is now read-only.

Commit c4e5b24

Browse files
committed
Allow usersettings to be saved for rest provider
`map-create-to-upsert` maps create to an upsert. Since we restrict patches and creates to the owner we have to provide the `user` object in the `hook.params`. This is done automatically when we add the authenticate hook with strategies `local` and `jwt`. Otherwise a http request will be rejected.
1 parent a979ee9 commit c4e5b24

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

server/services/usersettings/usersettings.hooks.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,13 @@
1+
const { iff, isProvider } = require('feathers-hooks-common');
12
const { restrictToOwner } = require('feathers-authentication-hooks');
23
const mapCreateToUpsert = require('../../hooks/map-create-to-upsert');
4+
const auth = require('@feathersjs/authentication');
35

46
module.exports = {
57
before: {
6-
all: [],
8+
all: [
9+
iff(isProvider('rest'), auth.hooks.authenticate('jwt'))
10+
],
711
find: [],
812
get: [],
913
create: [

0 commit comments

Comments
 (0)