Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- exports.createUser = (request, h) => {
- return bcrypt.hash(request.payload.password, 10).then(hash => {
- let user = new User({
- email: request.payload.email,
- username: request.payload.username,
- password: hash,
- admin: false
- });
- return user.save()
- .then(user => {
- return {
- _id: user._id,
- email: user.email,
- username: user.username,
- admin: user.admin
- };
- })
- .catch(error => {
- throw Boom.badRequest(error);
- });
- })
- .catch(error => {
- // ide kerül ha a bcrypt szarik be
- throw Boom.internal(error);
- });
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement