Delete password from user in login response
This commit is contained in:
parent
aa3d51702f
commit
dd6fa0e63c
@ -7,7 +7,7 @@ const { saltingRounds } = require('../../config/config');
|
|||||||
const { generateToken } = require('../../helpers/authJwt');
|
const { generateToken } = require('../../helpers/authJwt');
|
||||||
|
|
||||||
router.post('/register', async (req, res) => {
|
router.post('/register', async (req, res) => {
|
||||||
const data = req.body;
|
const data = req.body;
|
||||||
data.password = bcrypt.hashSync(data.password, saltingRounds);
|
data.password = bcrypt.hashSync(data.password, saltingRounds);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
@ -30,9 +30,9 @@ router.post('/login', async (req, res) => {
|
|||||||
|
|
||||||
if (bcrypt.compareSync(password, user.password)) {
|
if (bcrypt.compareSync(password, user.password)) {
|
||||||
const token = generateToken(user);
|
const token = generateToken(user);
|
||||||
|
delete user.password;
|
||||||
res.status(200).json({
|
res.status(200).json({
|
||||||
message: `Welcome ${user.username}!`,
|
user,
|
||||||
token,
|
token,
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
|
Loading…
Reference in New Issue
Block a user