Created
February 17, 2018 18:55
-
-
Save ImreC/59e2eebcf6f2a112df08ace8a8372b39 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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