Ocelot-Social/src/middleware/passwordMiddleware.js
Robert Schäfer 918bd863ed Fix typo
Replace password with Asterix and Obelix
See: http://www.topkool.com/fr/wp-content/uploads/2012/10/asterix-et-obelix-017.jpg

@appinteractive 😆
2019-01-17 18:06:53 +01:00

21 lines
613 B
JavaScript

import bcrypt from 'bcryptjs'
import walkRecursive from '../helpers/walkRecursive'
export default {
Mutation: {
CreateUser: async (resolve, root, args, context, info) => {
args.password = await bcrypt.hashSync(args.password, 10)
const result = await resolve(root, args, context, info)
result.password = '*****'
return result
}
},
Query: async (resolve, root, args, context, info) => {
const result = await resolve(root, args, context, info)
return walkRecursive(result, ['password'], () => {
// replace password with asterisk
return '*****'
})
}
}