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

module.exports = function(app, passport){
  app.post('/login', function(req, res, next) {
    passport.authenticate('local', function(err, user, info) {
      if (err) { return next(err); }
      if (!user) {
        if (/json/.test(req.headers.accept)) {
          res.send({ 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.send({ status: 'logged in' });
          return;
        }

        return res.redirect('./');
      });
    })(req, res, next);
  });
}<commit_msg>redirect was wrong in login.js<commit_after>// module.exports = function(app, passport) {
//   app.post('/login', passport.authenticate('local', {
//     successReturnToOrRedirect: './',
//     failureRedirect: '../login'
//   }));
// };

module.exports = function(app, passport){
  app.post('/login', function(req, res, next) {
    passport.authenticate('local', function(err, user, info) {
      if (err) { return next(err); }
      if (!user) {
        if (/json/.test(req.headers.accept)) {
          res.send({ 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.send({ status: 'logged in' });
          return;
        }

        return res.redirect('./');
      });
    })(req, res, next);
  });
}
{'fraction_non_alphanumeric': 0.19886363636363635, 'fraction_numerical': 0.0, 'mean_word_length': 2.127886323268206, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7449943', 'n_tokens_mistral': 561, 'n_tokens_neox': 541, 'n_words': 110}