code: function attemptLogin(req, res) {
      var username = req.param('username'),
          password = req.param('password'),
          next = req.param('next', '/');
  
      authdb.validate(username, password, function(err, valid) {
        if (valid) {
          req.session.authed = true;
          req.session.username = username;
          res.redirect(next);
        } else {
          res.emsg = 'Invalid Username or Password';
          render(req, res, 'login.jade', {next: next});
        }
      });
    }
docs: Handle Login attempts, redirect on success, render Login with error on failure