Skip to content

Instantly share code, notes, and snippets.

@ImreC
Created February 17, 2018 18:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ImreC/59e2eebcf6f2a112df08ace8a8372b39 to your computer and use it in GitHub Desktop.
Save ImreC/59e2eebcf6f2a112df08ace8a8372b39 to your computer and use it in GitHub Desktop.
const { authenticate } = require('@feathersjs/authentication').hooks;
const verifyHooks = require('feathers-authentication-management').hooks;
const accountService = require('../authmanagement/notifier');
const {
hashPassword, protect
} = require('@feathersjs/authentication-local').hooks;
module.exports = {
before: {
all: [],
find: [ authenticate('jwt') ],
get: [ authenticate('jwt') ],
create: [
hashPassword(),
verifyHooks.addVerification()
],
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: [
context => {
accountService(context.app).notifier('resendVerifySignup', context.result)
},
verifyHooks.removeVerification()
],
update: [],
patch: [],
remove: []
},
error: {
all: [],
find: [],
get: [],
create: [],
update: [],
patch: [],
remove: []
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment