How to use the feathers-hooks-common.disallow function in feathers-hooks-common

To help you get started, we’ve selected a few feathers-hooks-common 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 feathersjs-ecosystem / feathers-hooks-common / types / tests.ts View on Github external
checkContextIf(context1, 'before', ['update', 'patch'], 'hookName');

// $ExpectType Hook>
combine(hook1, hook2, hook3);

// $ExpectType Hook>
debug('label', 'abc.def', 'ghi.jkl');

// $ExpectType Hook>
dePopulate();

// $ExpectType Hook>
disablePagination();

// $ExpectType Hook>
disallow('external', 'server');

// $ExpectType Hook>
discard('abc', 'def');

// $ExpectType Hook>
discardQuery('abc', 'def');

softDelete({
    removeData: async () => ({})
});

const commentResolvers: ResolverMap = {
    joins: {
        author: $select => async comment => {
            const authors = await service1.find({
                query: { id: comment.userId, $select: $select || ['name'] },
github kalisio / krawler / src / cli.js View on Github external
if (Healthcheck.error) {
      res.status(500).json(_.pick(Healthcheck, ['jobId', 'error.code', 'error.message']))
    } else {
      res.status(200).json(_.omit(Healthcheck, ['error']))
    }
  })
  // Setup default services used by CLI
  TasksService.storesService = apiPrefix + '/stores'
  JobsService.storesService = apiPrefix + '/stores'
  JobsService.tasksService = apiPrefix + '/tasks'
  app.use(apiPrefix + '/stores', StoresService)
  app.use(apiPrefix + '/tasks', TasksService)
  app.use(apiPrefix + '/jobs', JobsService)
  // In API mode everything is open, otherwise only health check is
  if (!options.api) {
    app.service(apiPrefix + '/stores').hooks({ before: { all: [disallow('external')] } })
    app.service(apiPrefix + '/tasks').hooks({ before: { all: [disallow('external')] } })
    app.service(apiPrefix + '/jobs').hooks({ before: { all: [disallow('external')] } })
  }
  // Process hooks
  _.forOwn(job.hooks, (value, key) => {
    const service = app.service(apiPrefix + '/' + key)
    hooks.activateHooks(value, service)
  })
  // Run the app, this is required to correctly setup Feathers
  const port = options.port || 3030
  if (options.api) console.log('Server listening to ' + port)
  server = app.listen(port)
  if (sync) {
    server.on('close', () => app.sync.close())
  }
  await new Promise((resolve, reject) => {
github kalisio / krawler / src / cli.js View on Github external
} else {
      res.status(200).json(_.omit(Healthcheck, ['error']))
    }
  })
  // Setup default services used by CLI
  TasksService.storesService = apiPrefix + '/stores'
  JobsService.storesService = apiPrefix + '/stores'
  JobsService.tasksService = apiPrefix + '/tasks'
  app.use(apiPrefix + '/stores', StoresService)
  app.use(apiPrefix + '/tasks', TasksService)
  app.use(apiPrefix + '/jobs', JobsService)
  // In API mode everything is open, otherwise only health check is
  if (!options.api) {
    app.service(apiPrefix + '/stores').hooks({ before: { all: [disallow('external')] } })
    app.service(apiPrefix + '/tasks').hooks({ before: { all: [disallow('external')] } })
    app.service(apiPrefix + '/jobs').hooks({ before: { all: [disallow('external')] } })
  }
  // Process hooks
  _.forOwn(job.hooks, (value, key) => {
    const service = app.service(apiPrefix + '/' + key)
    hooks.activateHooks(value, service)
  })
  // Run the app, this is required to correctly setup Feathers
  const port = options.port || 3030
  if (options.api) console.log('Server listening to ' + port)
  server = app.listen(port)
  if (sync) {
    server.on('close', () => app.sync.close())
  }
  await new Promise((resolve, reject) => {
    server.on('listening', resolve)
    server.on('error', reject)
github Human-Connection / API / server / services / emotions / emotions.hooks.js View on Github external
const emotionRatingHook = require('./hooks/emotion-rating');
const { isVerified } = require('feathers-authentication-management').hooks;
const hooks = require('feathers-hooks-common');

module.exports = {
  before: {
    all: [authenticate('jwt')],
    find: [],
    get: [],
    create: [
      hooks.when(hooks.isProvider('external'),
        isVerified()
      )],
    update: [hooks.disallow()],
    patch: [hooks.disallow()],
    remove: [hooks.disallow('external')]
  },

  after: {
    all: [
      // populate({ schema: userSchema }),
      // populate({ schema: contributionSchema })
    ],
    find: [],
    get: [],
    create: [emotionRatingHook()],
    update: [],
    patch: [],
    remove: []
  },

  error: {
github Human-Connection / API / server / services / notifications / notifications.hooks.js View on Github external
const contributionSchema = {
  include: {
    service: 'contributions',
    nameAs: 'contribution',
    parentField: 'relatedContributionId',
    childField: '_id'
  }
};

module.exports = {
  before: {
    all: [ ],
    find: [ ...restrict ],
    get: [ ...restrict ],
    create: [ disallow('external') ],
    update: [ ...restrict ],
    patch: [ ...restrict ],
    remove: [ ...restrict ]
  },

  after: {
    all: [
      populate({ schema: contributionSchema }),
      populate({ schema: commentSchema })
    ],
    find: [],
    get: [],
    create: [],
    update: [],
    patch: [],
    remove: []
github codingfriend1 / Feathers-Vue / server / services / users / users.hooks.js View on Github external
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',
        'verifyChanges',
        'resetToken',
        'resetShortToken',
        'resetExpires'
      )),
      preventDisabledAdmin(),
      loopItems(setUserInitials)
github ImreC / feathers-verification-emails / src / services / users / users.hooks.js View on Github external
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',
            'resetExpires']
          ),
          hashPassword(),
github codingfriend1 / Feathers-Vue / server / services / email / email.hooks.js View on Github external
const { disallow } = require('feathers-hooks-common');

module.exports = {
  before: {
    all: [
      disallow('external')
    ],
    find: [],
    get: [],
    create: [],
    update: [],
    patch: [],
    remove: []
  },

  after: {
    all: [],
    find: [],
    get: [],
    create: [],
    update: [],
    patch: [],