Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
import * as globalHooks from '../../../hooks'
const hooks = require('feathers-hooks')
const auth = require('feathers-authentication')
const local = require('feathers-authentication-local')
const permissions = require('feathers-permissions')
const adminPermission = permissions.hooks.checkPermissions({
roles: ['ADMIN'],
on: 'user',
field: 'roles'
})
const before = {
all: [
],
find: [
adminPermission,
permissions.hooks.isPermitted(),
auth.hooks.authenticate('jwt')
],
get: [
auth.hooks.authenticate('jwt')
],
create: [
adminPermission,
permissions.hooks.isPermitted(),
local.hooks.hashPassword()
],
update: [
auth.hooks.authenticate('jwt'),
local.hooks.hashPassword()
],
patch: [
auth.hooks.authenticate('jwt'),
local.hooks.hashPassword()
],
remove: [
adminPermission,
permissions.hooks.isPermitted(),
auth.hooks.authenticate('jwt'),
]
}
const after = {
all: [hooks.remove('password')],
find: [],
get: [],
create: [],
update: [],
patch: [],
remove: []
}
export default {
before,
import { hooks as perms } from 'feathers-permissions';
import { setUUID } from '@/api/hooks/setUUID';
/**
Hook: before
Service: user
*/
export default {
all: [],
find: [
auth.authenticate(['jwt', 'local']),
perms.checkPermissions({ service: 'user' }),
],
get: [
auth.authenticate(['jwt', 'local']),
perms.checkPermissions({ service: 'user' }),
],
create: [
setUUID(),
local.hashPassword(),
],
update: [
auth.authenticate(['jwt', 'local']),
perms.checkPermissions({ service: 'user' }),
],
patch: [
auth.authenticate(['jwt', 'local']),
perms.checkPermissions({ service: 'user' }),
],
remove: [
auth.authenticate(['jwt', 'local']),
perms.checkPermissions({ service: 'user' }),