Skip to content
Snippets Groups Projects
Commit cb622c42 authored by V S Tharunika's avatar V S Tharunika
Browse files

adding endpoint for log in

parent bcb87e7a
Branches
No related tags found
No related merge requests found
......@@ -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'
})
}
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment