How to use the @feathersjs/authentication.hooks 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 / a-gens / js / test-authentication.test-expected / src1 / services / users-1 / users-1.hooks.js View on Github external
// Hooks for service `users1`. (Can be re-generated.)
const commonHooks = require('feathers-hooks-common');
const { authenticate } = require('@feathersjs/authentication').hooks;
// eslint-disable-next-line no-unused-vars
const { hashPassword, protect } = require('@feathersjs/authentication-local').hooks;
// !code: imports // !end

// ! 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('./users-1.validate');
// !end

// !code: init // !end

let moduleExports = {
  before: {
    // Your hooks should include:
github feathers-plus / generator-feathers-plus / test-expands / graphql-auth.test-expected / src1 / services / nedb-2 / nedb-2.hooks.js View on Github external
// Hooks for service `nedb2`. (Can be re-generated.)
const commonHooks = require('feathers-hooks-common');
const { authenticate } = require('@feathersjs/authentication').hooks;
// eslint-disable-next-line no-unused-vars
const nedb2Populate = require('./nedb-2.populate');
// !code: imports // !end

// ! 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:
github jenkins-infra / evergreen / services / src / app.js View on Github external
app.service('authentication').hooks({
  before: {
    create: [
      (context) => {
        /* Stringify the signature JSON to make the lookup() function in
         * passport-local/utils happy
         *
         * Somewhat related to
         * https://github.com/jaredhanson/passport-local/issues/153
         */
        if (context.data.signature) {
          context.data.password = JSON.stringify(context.data.signature);
        }
        return context;
      },
      authentication.hooks.authenticate(['local', 'jwt'])
    ]
  }
});

/*
 * Initialize the Sentry backend integration for reporting error telemetry
 */
app.set('sentry', new Sentry(process.env.SENTRY_URL || app.get('sentry').url));

if (process.env.NODE_ENV != 'production') {
  app.configure(swagger({
    docsPath: '/apidocs',
    uiIndex: true,
    info: {
      title: 'Evergreen Backend APIs',
      description:
github Human-Connection / API / server / services / comments / comments.hooks.js View on Github external
const { authenticate } = require('@feathersjs/authentication').hooks;
const { iff, unless, isProvider, populate, discard, softDelete, setNow } = require('feathers-hooks-common');
const { protect } = require('@feathersjs/authentication-local').hooks;
const {
  //queryWithCurrentUser,
  associateCurrentUser,
  // restrictToAuthenticated,
  restrictToOwner
} = require('feathers-authentication-hooks');
const { isVerified } = require('feathers-authentication-management').hooks;
const createExcerpt = require('../../hooks/create-excerpt');
const patchDeletedData = require('../../hooks/patch-deleted-data');
const concealBlacklistedData = require('../../hooks/conceal-blacklisted-data');
const keepDeletedDataFields = require('../../hooks/keep-deleted-data-fields');
const createNotifications = require('./hooks/create-notifications');
const createMentionNotifications = require('./hooks/create-mention-notifications');
const isModerator = require('../../hooks/is-moderator-boolean');
github feathers-plus / generator-feathers-plus / examples / js / 07-fakes / feathers-app / src / services / roles / roles.hooks.js View on Github external
// Hooks for service `roles`. (Can be re-generated.)
const commonHooks = require('feathers-hooks-common');
const { authenticate } = require('@feathersjs/authentication').hooks;
// !code: imports // !end

// ! 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('./roles.validate');
// !end

// !code: init // !end

let moduleExports = {
  before: {
    // Your hooks should include:
    //   all   : authenticate('jwt')
    // ! code: before
github feathers-plus / generator-feathers-plus / examples / js / 09-graphql / feathers-app / src / services / teams / teams.hooks.js View on Github external
// Hooks for service `teams`. (Can be re-generated.)
const commonHooks = require('feathers-hooks-common');
const { authenticate } = require('@feathersjs/authentication').hooks;
// !code: imports // !end

// ! 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('./teams.validate');
// !end

// !code: init // !end

let moduleExports = {
  before: {
    // Your hooks should include:
    //   all   : authenticate('jwt')
    // ! code: before
github timmo001 / home-panel / api / src / services / config / config.hooks.ts View on Github external
import * as authentication from '@feathersjs/authentication';
import processConfig from '../../hooks/process-config';
import processConfigUpdate from '../../hooks/process-config-update';
import populateUser from '../../hooks/populate-user';
// Don't remove this comment. It's needed to format import lines nicely.

const { authenticate } = authentication.hooks;

export default {
  before: {
    all: [authenticate('jwt')],
    find: [],
    get: [],
    create: [processConfig()],
    update: [processConfigUpdate()],
    patch: [processConfigUpdate()],
    remove: []
  },

  after: {
    all: [populateUser()],
    find: [],
    get: [],
github Human-Connection / API / server / services / projects / projects.hooks.js View on Github external
const { authenticate } = require('@feathersjs/authentication').hooks;
const createSlug = require('../../hooks/create-slug');
const saveRemoteImages = require('../../hooks/save-remote-images');

module.exports = {
  before: {
    all: [],
    find: [],
    get: [],
    create: [
      authenticate('jwt'),
      createSlug({ field: 'name' }),
      saveRemoteImages(['logo'])
    ],
    update: [
      authenticate('jwt'),
      createSlug({ field: 'name' }),
github Human-Connection / API / server / services / usersettings / usersettings.hooks.js View on Github external
const { associateCurrentUser, restrictToOwner } = require('feathers-authentication-hooks');
const {authenticate} = require('@feathersjs/authentication').hooks;

module.exports = {
  before: {
    all: [],
    find: [],
    get: [],
    create:  [
      authenticate('jwt'),
      associateCurrentUser()
    ],
    update: [
      authenticate('jwt'),
      restrictToOwner()
    ],
    patch: [
      authenticate('jwt'),
github jenkins-infra / evergreen / services / src / services / update / update.hooks.js View on Github external
getHooks() {
    return {
      before: {
        all: [
        ],
        find: [
          internalOnly,
        ],
        get: [
          authentication.hooks.authenticate(['jwt']),
          ensureMatchingUUID,
        ],
        create: [
          internalApi,
          this.checkUpdateFormat,
          dbtimestamp('createdAt'),
          this.defaultChannel,
          this.preventRedundantCommits,
        ],
        update: [
        ],
        patch: [
          internalApi,
          this.checkUpdateFormat,
          this.patchByCommitAndChannel,
          dbtimestamp('updatedAt'),