How to use the feathers-hooks-common.isProvider 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.

github Human-Connection / API / server / services / users / users.hooks.js View on Github external
search(),
      search({
        fields: ['name', 'email']
      })
    ],
    get: [],
    create: [
      hashPassword(),
      lowerCase('email', 'username'),
      when(isProvider('external'),
        inviteCode.before
      ),
      // We don't need email verification
      // for server generated users
      addVerification(),
      when(isProvider('server'),
        hook => {
          hook.data.isVerified = true;
          return hook;
        }
      ),
      when(isProvider('external'),
        restrictUserRole(),
        createAdmin()
      ),
      saveRemoteImages(['avatar', 'coverImg'])
    ],
    update: [
      ...restrict,
      hashPassword(),
      disableMultiItemChange(),
      lowerCase('email', 'username'),
github Human-Connection / API / server / services / contributions / contributions.hooks.js View on Github external
authenticate('jwt'),
      unless(isProvider('server'),
        isVerified(),
        canEditOrganization()
      ),
      unless(isModerator(),
        excludeDisabled(),
        restrictToOwner()
      ),
      saveRemoteImages(['teaserImg']),
      createExcerpt(),
      setNow('updatedAt')
    ],
    patch: [
      authenticate('jwt'),
      unless(isProvider('server'),
        isVerified(),
        canEditOrganization()
      ),
      unless(isModerator(),
        excludeDisabled(),
        restrictToOwner()
      ),
      saveRemoteImages(['teaserImg']),
      createExcerpt(),
      setNow('updatedAt'),
      // SoftDelete uses patch to delete items
      // Make changes to deleted items here
      patchDeletedData({
        data: {
          $set: {
            type: 'DELETED',
github Human-Connection / API / server / services / follows / follows.hooks.js View on Github external
parentField: 'foreignId',
    childField: '_id',
    query: {
      $select: ['_id', 'name', 'slug', 'avatar', 'createdAt', 'lastActiveAt']
    }
  }
};

module.exports = {
  before: {
    all: [],
    find: [],
    get: [],
    create: [
      authenticate('jwt'),
      unless(isProvider('server'),
        isVerified(),
        associateCurrentUser()
      )
      // mapCreateToUpsert(context => {
      //   const { data } = context;
      //   return { userId: data.userId, foreignId: data.foreignId, foreignService: data.foreignService };
      // })
    ],
    update: [
      authenticate('jwt'),
      unless(isModerator(),
        restrictToOwner()
      )
    ],
    patch: [
      authenticate('jwt'),
github Human-Connection / API / server / services / comments / comments.hooks.js View on Github external
}, restrictToOwner())
      ),
      createExcerpt({ length: 180 }),
      setNow('updatedAt'),
      // SoftDelete uses patch to delete items
      // Make changes to deleted items here
      patchDeletedData({
        data: {
          content: 'DELETED',
          contentExcerpt: 'DELETED'
        }
      })
    ],
    remove: [
      authenticate('jwt'),
      unless(isProvider('server'),
        unless(isModerator(),
          isVerified(),
          restrictToOwner()
        )
      )
    ]
  },

  after: {
    all: [
      xss({ fields: xssFields }),
      keepDeletedDataFields(),
      discard('wasSeeded')
    ],
    find: [
      populate({ schema: userSchema }),
github Human-Connection / API / server / services / emotions / emotions.hooks.js View on Github external
const { authenticate } = require('@feathersjs/authentication').hooks;
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: [],
github Human-Connection / API / server / services / users-candos / users-candos.hooks.js View on Github external
const { unless, isProvider } = require('feathers-hooks-common');
const isModerator = require('../../hooks/is-moderator-boolean');
const {
  associateCurrentUser,
  restrictToOwner
} = require('feathers-authentication-hooks');
const { isVerified } = require('feathers-authentication-management').hooks;
const setDoneDate = require('./hooks/set-done-date');

module.exports = {
  before: {
    all: [],
    find: [],
    get: [],
    create: [
      unless(isProvider('server'),
        authenticate('jwt'),
        isVerified(),
        associateCurrentUser()
      ),
      setDoneDate()
    ],
    update: [
      authenticate('jwt'),
      unless(isModerator(),
        restrictToOwner()
      ),
      setDoneDate()
    ],
    patch: [
      authenticate('jwt'),
      unless(isModerator(),
github Human-Connection / API / server / services / invites / invites.hooks.js View on Github external
const { when, isProvider, lowerCase } = require('feathers-hooks-common');
const isAdmin = require('../../hooks/is-admin');

const sendInviteEmail = require('./hooks/send-invite-email');
const restrictAPIToAdmin = when(isProvider('external'),
  isAdmin()
);

module.exports = {
  before: {
    all: [
      restrictAPIToAdmin
    ],
    find: [],
    get: [],
    create: [
      lowerCase('email', 'username')
    ],
    update: [],
    patch: [],
    remove: []
github Human-Connection / API / server / services / pages / pages.hooks.js View on Github external
before: {
    all: [],
    find: [],
    get: [],
    create: [
      authenticate('jwt'),
      unless(isProvider('server'),
        isVerified(),
        isAdmin()
      ),
      createSlug({ field: 'key', unique: false }),
      cleanupHTML()
    ],
    update: [
      authenticate('jwt'),
      unless(isProvider('server'),
        isVerified(),
        isAdmin()
      ),
      cleanupHTML()
    ],
    patch: [
      authenticate('jwt'),
      unless(isProvider('server'),
        isVerified(),
        isAdmin()
      ),
      cleanupHTML()
    ],
    remove: [
      authenticate('jwt'),
      isVerified(),
github ImreC / feathers-verification-emails / src / services / users / users.hooks.js View on Github external
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(),
          authenticate('jwt')
        )
    ],
    remove: [ authenticate('jwt') ]