From dd6fa0e63c73f2a90fb26e65e2094dacdfddb151 Mon Sep 17 00:00:00 2001 From: rui hildt Date: Sat, 9 May 2020 14:58:22 +0200 Subject: [PATCH] Delete password from user in login response --- api/routes/authRoute.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/api/routes/authRoute.js b/api/routes/authRoute.js index 48005bc..10be4b2 100644 --- a/api/routes/authRoute.js +++ b/api/routes/authRoute.js @@ -7,7 +7,7 @@ const { saltingRounds } = require('../../config/config'); const { generateToken } = require('../../helpers/authJwt'); router.post('/register', async (req, res) => { - const data = req.body; + const data = req.body; data.password = bcrypt.hashSync(data.password, saltingRounds); try { @@ -30,9 +30,9 @@ router.post('/login', async (req, res) => { if (bcrypt.compareSync(password, user.password)) { const token = generateToken(user); - + delete user.password; res.status(200).json({ - message: `Welcome ${user.username}!`, + user, token, }); } else {