Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
auth.restrictToAuthenticated(),
globalHooks.isEnabled(),
globalHooks.hasPermission('manageUsers')
],
get: [
auth.verifyToken(),
auth.populateUser(),
auth.restrictToAuthenticated(),
globalHooks.isEnabled(),
globalHooks.hasPermission('manageUsers')
// auth.restrictToOwner({ ownerField: '_id' })
],
create: [
auth.hashPassword(),
common.lowerCase('email'),
verifyHooks.addVerification(),
globalHooks.setDefaultRole(),
globalHooks.setFirstUserToRole({role: 'admin'})
],
update: [
auth.verifyToken(),
auth.populateUser(),
auth.restrictToAuthenticated(),
globalHooks.isEnabled(),
globalHooks.hasPermissionOrRestrictChanges('manageUsers', {
restrictOn: ['role', 'isEnabled']
}),
globalHooks.preventDisabledAdmin()
],
patch: [
auth.verifyToken(),
auth.populateUser(),
const verifyHooks = require('feathers-authentication-management').hooks;
const accountService = require('../authmanagement/notifier');
const commonHooks = require('feathers-hooks-common');
const {
hashPassword, protect
} = require('@feathersjs/authentication-local').hooks;
module.exports = {
before: {
all: [],
find: [ authenticate('jwt') ],
get: [ authenticate('jwt') ],
create: [
hashPassword(),
verifyHooks.addVerification()
],
update: [
commonHooks.disallow('external')
],
patch: [
commonHooks.iff(
commonHooks.isProvider('external'),
commonHooks.preventChanges(true,
['email',
'isVerified',
'verifyToken',
'verifyShortToken',
'verifyExpires',
'verifyChanges',
'resetToken',
'resetShortToken',
};
module.exports = {
before: {
all: [],
find: [
authenticate('jwt'),
isEnabled(),
],
get: [
authenticate('jwt'),
isEnabled(),
],
create: [
hashPassword(),
verifyHooks.addVerification(),
setDefaultRole(),
setFirstUserToRole({role: 'admin'}),
preventDisabledAdmin(),
loopItems(setUserInitials)
],
update: [
commonHooks.disallow('external')
],
patch: [
...restrict,
commonHooks.iff(commonHooks.isProvider('external'), commonHooks.preventChanges(
'email',
'isVerified',
'verifyToken',
'verifyShortToken',
'verifyExpires',