var passport = require('passport');

// module.exports = function(app, passport) {
//   app.post('/login', passport.authenticate('local', {
//     successReturnToOrRedirect: './',
//     failureRedirect: '../login'
//   }));
// };

module.exports = function(app, protect){
  app.get('/login$', function(req, res, next){
    // handled by express.static after this
    return res.redirect('./login/');
  });

  app.post('/login', function(req, res, next) {
    passport.authenticate('local', function(err, user, info) {
      console.log({ err, user, info });
      if (err) { return next(err); }
      if (!user) {
        if (/json/.test(req.headers.accept)) {
          res.json({ status: 'no user' });
          return;
        }
        return res.redirect('./login');
      }
      req.logIn(user, function(err) {
        if (err) { return next(err); }

        if (/json/.test(req.headers.accept)) {
          res.json({ status: 'logged in' });
          return;
        }

        return res.redirect('./');
      });
    })(req, res, next);
  });
};

@@ -516,48 +516,8 @@
 ) %7B%0A
-      console.log(%7B err, user, info %7D);%0A
     

Revert "troubleshooting auth"