I follow the average video stacks made by Microsoft Visual Academy (mva). I was amazed at MVA module 3. When I enter the username and password, it is always redirected to the failure route.
passport.js:
passport.use('signup', new LocalStrategy({
passReqToCallback : true
},
function(req, username, password, done) {
if (users[username]){
console.log('User already exists with username: ' + username);
return done(null, false);
}
users[username] = {
username: username,
password: createHash(password)
}
console.log(users[username].username + ' Registration successful');
return done(null, users[username]);
})
);
authenticate.js:
router.get('/success', function(req, res){
res.send({state: 'success', user: req.user ? req.user : null});
});
router.get('/failure', function(req, res){
res.send({state: 'failure', user: null, message: "Invalid username or password"});
});
router.post('/login', passport.authenticate('login', {
successRedirect: '/auth/success',
failureRedirect: '/auth/failure'
}));
I really followed the steps indicated at https://github.com/hwz/chirp/tree/master/module-3
Any help is appreciated. Thanks in advance:)
user5186342
source
share