I'm using passport for user authentication and it is working fine, but i wan't to change the message 'Unauthorized' when the user login or password is wrong.
Here is the code for the user authentication:
app.get('/login', function(req, res){
res.render('login');
})
app.post('/login', function(req, res){
const user = new User({
username: req.body.username,
password: req.body.password
});
req.login(user, function(err){
if(err){
res.send('Erro')
} else{
passport.authenticate('local')(req, res, function(){
if(user){
res.send('Positive')
} else{
res.send('Negative')
}
})
}
})
});
It returns 'positive' if the user type the correct login and password, but if the login and password is wrong, it returns 'Unauthorized' instead of 'negative'