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

Commit 796afdb

Browse files
replaced discard on after hooks with protect
1 parent ff98e78 commit 796afdb

File tree

2 files changed

+6
-8
lines changed

2 files changed

+6
-8
lines changed

server/services/comments/comments.hooks.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
const { authenticate } = require('@feathersjs/authentication').hooks;
22
const { unless, isProvider, populate, discard, softDelete, setNow } = require('feathers-hooks-common');
3+
const { protect } = require('@feathersjs/authentication-local').hooks;
34
const {
45
//queryWithCurrentUser,
56
associateCurrentUser,
@@ -108,7 +109,7 @@ module.exports = {
108109
],
109110
find: [
110111
populate({ schema: userSchema }),
111-
discard('content', 'badgeIds')
112+
protect('content', 'badgeIds')
112113
],
113114
get: [
114115
populate({ schema: userSchema })

server/services/users/users.hooks.js

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
// const { authenticate } = require('feathers-authentication').hooks;
2-
const { isProvider, when, iff, discard, populate, disableMultiItemChange, lowerCase } = require('feathers-hooks-common');
2+
const { isProvider, when, iff, populate, disableMultiItemChange, lowerCase } = require('feathers-hooks-common');
3+
const { protect } = require('@feathersjs/authentication-local').hooks;
34
const { restrictToOwner } = require('feathers-authentication-hooks');
45
const { addVerification, removeVerification } = require('feathers-authentication-management').hooks;
56

@@ -17,12 +18,8 @@ const removeAllRelatedUserData = require('./hooks/remove-all-related-user-data')
1718

1819
const { hashPassword } = require('@feathersjs/authentication-local').hooks;
1920

20-
const cleanupBasicData = when(isProvider('external'),
21-
discard('password', '_computed', 'verifyExpires', 'resetExpires', 'verifyChanges')
22-
);
23-
const cleanupPersonalData = when(isProvider('external'),
24-
discard('email', 'verifyToken', 'verifyShortToken', 'doiToken', 'systemNotificationsSeen')
25-
);
21+
const cleanupBasicData = protect('password', '_computed', 'verifyExpires', 'resetExpires', 'verifyChanges');
22+
const cleanupPersonalData = protect('email', 'verifyToken', 'verifyShortToken', 'doiToken', 'systemNotificationsSeen');
2623

2724
const restrict = [
2825
restrictToOwner({

0 commit comments

Comments
 (0)