Skip to content

Commit

Permalink
fix: fix response of POST /register
Browse files Browse the repository at this point in the history
Fix #8
  • Loading branch information
matheuspiment committed Oct 8, 2019
1 parent 414017c commit 3922868
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 4 deletions.
4 changes: 2 additions & 2 deletions src/controllers/UserController.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Request, Response } from 'express'
import * as Yup from 'yup'
import omit from 'lodash/omit'
import pick from 'lodash/pick'

import User from '../schemas/User'
import CheckUserEmail from '../services/CheckUserEmail'
Expand All @@ -25,7 +25,7 @@ class UserController {
}

const user = await User.create(req.body)
return res.json(omit(user.toObject(), ['password']))
return res.json(pick(user.toObject(), ['_id', 'name', 'email']))
} catch (err) {
return res.status(400).json({ error: 'Registration failed' })
}
Expand Down
3 changes: 1 addition & 2 deletions src/schemas/User.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,7 @@ const UserSchema = new Schema({
},
password: {
type: String,
required: true,
select: false
required: true
}
}, {
versionKey: false,
Expand Down

0 comments on commit 3922868

Please sign in to comment.