How to use the @feathersjs/authentication.authenticate function in @feathersjs/authentication

To help you get started, we’ve selected a few @feathersjs/authentication 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-2-test-auth.test-expected / src1 / services / users1 / users1.hooks.js View on Github external
before: {
    // Your hooks should include:
    //   find  : authenticate('jwt')
    //   get   : authenticate('jwt')
    //   create: hashPassword()
    //   update: hashPassword(), authenticate('jwt')
    //   patch : hashPassword(), authenticate('jwt')
    //   remove: authenticate('jwt')
    // ! 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
  },
github feathers-plus / generator-feathers-plus / test-expands / cumulative-6-generators.test-expected / src1 / services / nedb1 / nedb1.hooks.js View on Github external
// ! code: used
// eslint-disable-next-line no-unused-vars
const { iff } = commonHooks;
// eslint-disable-next-line no-unused-vars
const { create, update, patch, validateCreate, validateUpdate, validatePatch } = require('./nedb1.validate');
// !end

// !code: init // !end

let moduleExports = {
  before: {
    // Your hooks should include:
    //   all   : authenticate('jwt')
    // ! code: before
    all: [ authenticate('jwt') ],
    find: [],
    get: [],
    create: [],
    update: [],
    patch: [],
    remove: []
    // !end
  },

  after: {
    // ! code: after
    all: [],
    find: [],
    get: [],
    create: [],
    update: [],
github feathers-plus / generator-feathers-plus / test / cumulative-1-mongo.test-expected / src1 / services / nedb-1 / nedb-1.hooks.js View on Github external
// eslint-disable-next-line no-unused-vars
const foreignKeys = [
  'id',
  '_id',
  'nedb2Id'
];
// !end
// !code: init // !end

let moduleExports = {
  before: {
    // Your hooks should include:
    //   all   : authenticate('jwt')
    //   find  : mongoKeys(ObjectID, foreignKeys)
    // ! code: before
    all: [ authenticate('jwt') ],
    find: [ mongoKeys(ObjectID, foreignKeys) ],
    get: [],
    create: [],
    update: [],
    patch: [],
    remove: []
    // !end
  },

  after: {
    // ! code: after
    all: [],
    find: [],
    get: [],
    create: [],
    update: [],
github feathers-plus / generator-feathers-plus / test-expands / graphql-auth.test-expected / src1 / services / nedb-2 / nedb-2.hooks.js View on Github external
// ! code: used
// eslint-disable-next-line no-unused-vars
const { iff } = commonHooks;
// eslint-disable-next-line no-unused-vars
const { create, update, patch, validateCreate, validateUpdate, validatePatch } = require('./nedb-2.validate');
// !end

// !code: init // !end

let moduleExports = {
  before: {
    // Your hooks should include:
    //   all   : authenticate('jwt')
    // ! code: before
    all: [ authenticate('jwt') ],
    find: [],
    get: [],
    create: [],
    update: [],
    patch: [],
    remove: []
    // !end
  },

  after: {
    // ! code: after
    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
// !end

// !code: init // !end

let moduleExports = {
  before: {
    // Your hooks should include:
    //   find  : authenticate('jwt')
    //   get   : authenticate('jwt')
    //   create: hashPassword()
    //   update: hashPassword(), authenticate('jwt')
    //   patch : hashPassword(), authenticate('jwt')
    //   remove: authenticate('jwt')
    // ! 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: [],
github ImreC / feathers-verification-emails / src / services / users / users.hooks.js View on Github 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') ]
  },

  after: {
    all: [
      // Make sure the password field is never sent to the client
      // Always must be the last hook
      protect('password')
    ],
    find: [],
    get: [],
    create: [
      context => {
        accountService(context.app).notifier('resendVerifySignup', context.result)
github ImreC / feathers-verification-emails / src / services / users / users.hooks.js View on Github external
const { authenticate } = require('@feathersjs/authentication').hooks;
const verifyHooks = require('feathers-authentication-management').hooks;
const accountService = require('../authmanagement/notifier');
const commonHooks = require('feathers-hooks-common');

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',
github Human-Connection / API / server / services / images / images.hooks.js View on Github external
associateCurrentUser,
  restrictToOwner
} = require('feathers-authentication-hooks');

module.exports = {
  before: {
    all: [],
    find: [],
    get: [],
    create: [
      authenticate('jwt'),
      associateCurrentUser(),
      uploadFile()
    ],
    update: [
      authenticate('jwt'),
      restrictToOwner()
    ],
    patch: [
      authenticate('jwt'),
      restrictToOwner()
    ],
    remove: [
      authenticate('jwt'),
      restrictToOwner()
    ]
  },

  after: {
    all: [],
    find: [],
    get: [],
github CodingGarden / trello-clone / server / src / services / lists / lists.hooks.js View on Github external
const { authenticate } = require('@feathersjs/authentication').hooks;
const { isBoardOwner } = require('../../hooks/authorization');

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

  after: {
    all: [],
    find: [],
    get: [],
    create: [],
    update: [],
    patch: [],
    remove: []
github Human-Connection / API / server / services / users-candos / users-candos.hooks.js View on Github external
unless(isProvider('server'),
        authenticate('jwt'),
        isVerified(),
        associateCurrentUser()
      ),
      setDoneDate()
    ],
    update: [
      authenticate('jwt'),
      unless(isModerator(),
        restrictToOwner()
      ),
      setDoneDate()
    ],
    patch: [
      authenticate('jwt'),
      unless(isModerator(),
        restrictToOwner()
      ),
      setDoneDate()
    ],
    remove: [
      authenticate('jwt'),
      unless(isModerator(),
        restrictToOwner()
      )
    ]
  },

  after: {
    all: [],
    find: [],