Skip to content

Commit 85b3cc2

Browse files
committed
feat: protect all services
1 parent 8f48be5 commit 85b3cc2

File tree

3 files changed

+15
-4
lines changed

3 files changed

+15
-4
lines changed

services/feedback/feedback.hooks.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { populate, discard } from 'feathers-hooks-common';
1+
import { populate, discard, disallow } from 'feathers-hooks-common';
22
import requireAuth from '../../hooks/requireAuth';
33
import signAuthority from '../../hooks/signAuthority';
44
import sortByDate from '../../hooks/sortByDate';
@@ -18,7 +18,10 @@ const populateAuthor = populate({
1818
export default {
1919
before: {
2020
create: [requireAuth, signAuthority],
21-
find: sortByDate
21+
find: sortByDate,
22+
remove: disallow('external'),
23+
patch: disallow('external'),
24+
update: disallow('external')
2225
},
2326
after: {
2427
all: [populateAuthor, discard('authorId')]

services/polls/polls.hooks.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { HookContext } from '@feathersjs/feathers';
2+
import { disallow } from 'feathers-hooks-common';
23
import { Types } from 'mongoose';
34
import bluebird from 'bluebird'; import _ from 'lodash';
45
import { Poll } from 'which-types';
@@ -46,7 +47,10 @@ const convertPoll = async (context: HookContext): Promise<HookContext> => {
4647
export default {
4748
before: {
4849
find: sortByDate,
49-
create: signAuthority
50+
create: signAuthority,
51+
remove: disallow('external'),
52+
update: disallow('external'),
53+
patch: disallow('external')
5054
},
5155
after: {
5256
all: convertPoll

services/votes/votes.hooks.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,13 @@
1+
import { disallow } from 'feathers-hooks-common';
12
import requireAuth from '../../hooks/requireAuth';
23
import signAuthority from '../../hooks/signAuthority';
34

45
export default {
56
before: {
6-
create: [requireAuth, signAuthority]
7+
create: [requireAuth, signAuthority],
8+
remove: disallow('external'),
9+
update: disallow('external'),
10+
patch: disallow('external')
711
}
812
};
913

0 commit comments

Comments
 (0)