Skip to content
Snippets Groups Projects
Commit 2ff94c66 authored by Lucas Gabriel Lima's avatar Lucas Gabriel Lima
Browse files

small fix on /authenticate

parent d4f0295a
No related branches found
No related tags found
2 merge requests!116Release v1.0.0,!25Auth
Pipeline #
...@@ -48,7 +48,14 @@ userApp.post('/', (req, res, next) => { ...@@ -48,7 +48,14 @@ userApp.post('/', (req, res, next) => {
}); });
}); });
userApp.post('/authenticate', (req, res) => { userApp.post('/authenticate', (req, res, next) => {
if (!req.body.email || !req.body.password) {
res.json({success: false, msg: 'Please pass email and password.'});
} else {
next();
}
}, (req, res, next) => {
User.findOne({ User.findOne({
email: req.body.email email: req.body.email
}, (err, user) => { }, (err, user) => {
...@@ -71,9 +78,9 @@ userApp.post('/authenticate', (req, res) => { ...@@ -71,9 +78,9 @@ userApp.post('/authenticate', (req, res) => {
else { else {
res.json({success: false, msg: 'Authentication failed. Wrong password'}); res.json({success: false, msg: 'Authentication failed. Wrong password'});
} }
}) });
} }
}) });
}) });
module.exports = userApp; module.exports = userApp;
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment