How to use the @feathersjs/authentication-local.protect function in @feathersjs/authentication-local

To help you get started, we’ve selected a few @feathersjs/authentication-local 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 feathers-plus / generator-feathers-plus / test-expands / cumulative-1-mongo.test-expected / src1 / services / users-1 / users-1.hooks.js View on Github external
// ! code: before
    all: [],
    find: [ authenticate('jwt'), mongoKeys(ObjectID, foreignKeys) ],
    get: [ authenticate('jwt') ],
    create: [ hashPassword() ],
    update: [ hashPassword(), authenticate('jwt') ],
    patch: [ hashPassword(), authenticate('jwt') ],
    remove: [ authenticate('jwt') ]
    // !end
  },

  after: {
    // Your hooks should include:
    //   all   : protect('password') /* Must always be the last hook */
    // ! code: after
    all: [ protect('password') /* Must always be the last hook */ ],
    find: [],
    get: [],
    create: [],
    update: [],
    patch: [],
    remove: []
    // !end
  },

  error: {
    // ! code: error
    all: [],
    find: [],
    get: [],
    create: [],
    update: [],
github feathers-plus / generator-feathers-plus / test-expands / authentication-2.test-expected / src1 / services / users-1 / users-1.hooks.js View on Github external
// ! code: before
    all: [],
    find: [ authenticate('jwt') ],
    get: [ authenticate('jwt') ],
    create: [ hashPassword() ],
    update: [ hashPassword(), authenticate('jwt') ],
    patch: [ hashPassword(), authenticate('jwt') ],
    remove: [ authenticate('jwt') ]
    // !end
  },

  after: {
    // Your hooks should include:
    //   all   : protect('password') /* Must always be the last hook */
    // ! code: after
    all: [ protect('password') /* Must always be the last hook */ ],
    find: [],
    get: [],
    create: [],
    update: [],
    patch: [],
    remove: []
    // !end
  },

  error: {
    // ! code: error
    all: [],
    find: [],
    get: [],
    create: [],
    update: [],
github feathers-plus / generator-feathers-plus / test-expands / cumulative-6-generators.test-expected / src1 / services / users1 / users1.hooks.js View on Github external
// ! code: before
    all: [],
    find: [ authenticate('jwt') ],
    get: [ authenticate('jwt') ],
    create: [ hashPassword() ],
    update: [ hashPassword(), authenticate('jwt') ],
    patch: [ hashPassword(), authenticate('jwt') ],
    remove: [ authenticate('jwt') ]
    // !end
  },

  after: {
    // Your hooks should include:
    //   all   : protect('password') /* Must always be the last hook */
    // ! code: after
    all: [ protect('password') /* Must always be the last hook */ ],
    find: [],
    get: [],
    create: [],
    update: [],
    patch: [],
    remove: []
    // !end
  },

  error: {
    // ! code: error
    all: [],
    find: [],
    get: [],
    create: [],
    update: [],
github feathers-plus / generator-feathers-plus / test-expands / cumulative-2-test-auth.test-expected / src1 / services / users1 / users1.hooks.js View on Github external
// ! code: before
    all: [],
    find: [ authenticate('jwt') ],
    get: [ authenticate('jwt') ],
    create: [ hashPassword() ],
    update: [ hashPassword(), authenticate('jwt') ],
    patch: [ hashPassword(), authenticate('jwt') ],
    remove: [ authenticate('jwt') ]
    // !end
  },

  after: {
    // Your hooks should include:
    //   all   : protect('password') /* Must always be the last hook */
    // ! code: after
    all: [ protect('password') /* Must always be the last hook */ ],
    find: [],
    get: [],
    create: [],
    update: [],
    patch: [],
    remove: []
    // !end
  },

  error: {
    // ! code: error
    all: [],
    find: [],
    get: [],
    create: [],
    update: [],
github silvestreh / feathers-nuxt / src / services / users / users.hooks.js View on Github external
module.exports = {
  before: {
    all: [],
    find: [ authenticate('jwt') ],
    get: [ authenticate('jwt') ],
    create: [ hashPassword() ],
    update: [ hashPassword(),  authenticate('jwt') ],
    patch: [ hashPassword(),  authenticate('jwt') ],
    remove: [ authenticate('jwt') ]
  },

  after: {
    all: [
      // Make sure the password field is never sent to the client
      // Always must be the last hook
      protect('password')
    ],
    find: [],
    get: [],
    create: [],
    update: [],
    patch: [],
    remove: []
  },

  error: {
    all: [],
    find: [],
    get: [],
    create: [],
    update: [],
    patch: [],
github ijjk / mykb / src / services / users / users.hooks.js View on Github external
const { newPassword } = ctx.data
        if (invalidStr(newPassword)) invalid('newPassword')
        ctx.data = { password: newPassword }
        await hashPassword()(ctx)
        ctx.app.authLimit.resetKey(ctx.params.ip)
        return ctx
      },
    ],
    remove: [authenticate('jwt'), adminOnly],
  },

  after: {
    all: [
      // Make sure the password field is never sent to the client
      // Always must be the last hook
      protect('password'),
    ],
    find: [],
    get: [],
    create: [
      async ctx => {
        const { app } = ctx
        if (app.get('didSetup')) return ctx
        app.set('didSetup', true)
        fs.writeFileSync(
          // create empty file so we cant stat it
          path.join(__dirname, '..', '..', '..', 'db', '.didSetup'),
          ''
        )
        return ctx
      },
    ],
github stalniy / casl-feathersjs-example / src / services / users / users.hooks.js View on Github external
module.exports = {
  before: {
    all: [
    ],
    find: [ ],
    get: [ ],
    create: [ hashPassword() ],
    update: [ hashPassword() ],
    patch: [ hashPassword() ],
    remove: [ ]
  },

  after: {
    all: [
      protect('password')
    ],
    find: [],
    get: [],
    create: [],
    update: [],
    patch: [],
    remove: []
  },

  error: {
    all: [],
    find: [],
    get: [],
    create: [],
    update: [],
    patch: [],
github Human-Connection / API / server / services / users / users.hooks.js View on Github external
const sendVerificationEmail = require('./hooks/send-verification-email');
const restrictUserRole = require('./hooks/restrict-user-role');
const createAdmin = require('./hooks/create-admin');
const createSlug = require('../../hooks/create-slug');
const thumbnails = require('../../hooks/thumbnails');
const isModerator = require('../../hooks/is-moderator-boolean');
const isSingleItem = require('../../hooks/is-single-item');
const inviteCode = require('./hooks/invite-code')();
const search = require('feathers-mongodb-fuzzy-search');
const isOwnEntry = require('./hooks/is-own-entry');
const removeAllRelatedUserData = require('./hooks/remove-all-related-user-data');

const { hashPassword } = require('@feathersjs/authentication-local').hooks;

const cleanupBasicData = protect('password', '_computed', 'verifyExpires', 'resetExpires', 'verifyChanges');
const cleanupPersonalData = protect('email', 'verifyToken', 'verifyShortToken', 'doiToken', 'systemNotificationsSeen');

const restrict = [
  restrictToOwner({
    idField: '_id',
    ownerField: '_id'
  })
];

const badgesSchema = {
  include: {
    service: 'badges',
    nameAs: 'badges',
    parentField: 'badgeIds',
    childField: '_id',
    asArray: true
github Human-Connection / API / server / services / comments / comments.hooks.js View on Github external
isVerified(),
          restrictToOwner()
        )
      )
    ]
  },

  after: {
    all: [
      xss({ fields: xssFields }),
      keepDeletedDataFields(),
      discard('wasSeeded')
    ],
    find: [
      populate({ schema: userSchema }),
      protect('content', 'badgeIds'),
      concealBlacklistedData({
        data: {
          content: 'Comments of this blacklisted user are not visible.',
          contentExcerpt: 'Comments of this blacklisted user are not visible.',
          hasMore: false
        }
      })
    ],
    get: [
      populate({ schema: userSchema }),
      concealBlacklistedData({
        data: {
          content: 'Comments of this blacklisted user are not visible.',
          contentExcerpt: 'Comments of this blacklisted user are not visible.',
          hasMore: false
        }
github claustres / quasar-feathers-tutorial / quasar-feathers / api / src / services / users / users.hooks.js View on Github external
module.exports = {
  before: {
    all: [],
    find: [ authenticate('jwt') ],
    get: [ authenticate('jwt') ],
    create: [hashPassword(), gravatar()],
    update: [ authenticate('jwt') ],
    patch: [ authenticate('jwt') ],
    remove: [ authenticate('jwt') ]
  },

  after: {
    all: [
      commonHooks.when(
        hook => hook.params.provider,
        protect('password')
      )
    ],
    find: [],
    get: [],
    create: [],
    update: [],
    patch: [],
    remove: []
  },

  error: {
    all: [],
    find: [],
    get: [],
    create: [],
    update: [],