I have been following mean stack videos done by microsoft visual academy(mva). I have been struck at module 3 of MVA. When I enter a username and password, it always redirects to failure route.

passport.js:

```
passport.use('signup', new LocalStrategy({
        passReqToCallback : true // allows us to pass back the entire request to the callback
    },
    function(req, username, password, done) {

        if (users[username]){
            console.log('User already exists with username: ' + username);
            return done(null, false);
        }

        //store user in memory 
        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});
});

//sends failure login state back to angular
router.get('/failure', function(req, res){
    res.send({state: 'failure', user: null, message: "Invalid username or password"});
});

//log in
router.post('/login', passport.authenticate('login', {
    successRedirect: '/auth/success',
    failureRedirect: '/auth/failure'
}));

```

[![enter image description here](https://i.stack.imgur.com/JmGbt.png)](https://i.stack.imgur.com/JmGbt.png)

I actually followed steps given in <https://github.com/hwz/chirp/tree/master/module-3>

Any help is appreciated. Thanks in advance :)