How to use the feathers-permissions.hooks function in feathers-permissions

To help you get started, we’ve selected a few feathers-permissions examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github implustech / famn / app / service / user / hooks / index.ts View on Github external
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')
  ],
github implustech / famn / app / service / user / hooks / index.ts View on Github external
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,

feathers-permissions

Simple permissions module for Feathers

MIT
Latest version published 3 years ago

Package Health Score

60 / 100
Full package analysis