diff --git a/server/src/controllers/AuthenticationController.js b/server/src/controllers/AuthenticationController.js index 6209cfb26a62ac63937e2428883720214e896cd7..ae68a73d3cc6ce58862a4d88f5197e50dfdff881 100644 --- a/server/src/controllers/AuthenticationController.js +++ b/server/src/controllers/AuthenticationController.js @@ -23,14 +23,23 @@ module.exports={ } }) if (!user) { - res.status(403).send({ + return res.status(403).send({ error: 'The login information was incorrect' }) } - res.send(user.toJSON()) + const isPasswordValid = password === user.password + if(!isPasswordValid) { + return res.status(403).send({ + error: 'The login information was incorrect' + }) + } + const userJson = user.toJSON() + res.send({ + user: userJSON + }) }catch (err){ - res.status(400).send({ - error: 'This email account is already in use.' + res.status(500).send({ + error: 'An error has occured trying to log in' }) } }