<commit_before>// var express = require('express');
// // var passport = require('passport');
// // var LocalStrategy = require('passport-local').Strategy;
// var User = require('../models/User');
// var router = express.Router();

// configure passport
// passport.use(new LocalStrategy(User.authenticate()));
// passport.serializeUser(User.serializeUser());
// passport.deserializeUser(User.deserializeUser());
// end configuration for passport


router.get('/', function(req, res){
  res.render('login', { user: req.user });
});

router.post('/', function(req, res) {

});
// router.get('/login', function(req, res){
//   res.render('login', { user: req.user });
// });
//
// router.post('/login', passport.authenticate('local', { failureRedirect: '/user' }), function(req, res) {
//   res.redirect('/');
// });
//
// router.get('/register', function(req, res){
//   // res.render('register', { user: req.user });
// });
//
// router.post('/register', function(req, res){
//   User.register(new User({
//     username: req.body.username //from the form
//   }),
//   req.body.password,
//   function(err, account) {
//     if (err) {
//       return res.render('register', { account: account });
//     }
//     // passport.authenticate('local') is a function
//     passport.authenticate('local')(req, res, function() {
//       res.redirect('/');
//     });
//   });
//
// });

router.get('/logout', function(req, res){
  req.logout();
  res.redirect('/');
});



module.exports = router;<commit_msg>updated user router back to RESTful<commit_after>var express = require('express');
// // var passport = require('passport');
// // var LocalStrategy = require('passport-local').Strategy;
var user = require('../models/User');
var router = express.Router();

// configure passport
// passport.use(new LocalStrategy(User.authenticate()));
// passport.serializeUser(User.serializeUser());
// passport.deserializeUser(User.deserializeUser());
// end configuration for passport

router.get('/', function(req, res, next) {
  model.find(function(err, users) {
    if (err) {
      res.json(buildErrorResponse(err));
    } else {
      res.json(users);
    }
  });
});

router.get('/:id', function(req, res, next) {
  model.findById(req.params.id, function(err, user) {
    if (err) {
      res.json(buildErrorResponse(err));
    } else {
      res.json(user);
    }
  });
});

router.post('/', function(req, res, next) {
  model.create(req.body, function(err, user) {
    if (err) {
      res.json(buildErrorResponse(err));
    } else {
      res.json(user);
    }
  });
});

router.put('/:id', function(req, res, next) {
  model.findByIdAndUpdate(req.params.id, req.body, function(err, user) {
    if (err) {
      res.json(buildErrorResponse(err));
    } else {
      res.json(user);
    }
  });
});

router.patch('/:id', function(req, res, next) {
  model.findByIdAndUpdate(req.params.id, req.body, function(err, user) {
    if (err) {
      res.json(buildErrorResponse(err));
    } else {
      res.json(user);
    }
  });
});


router.delete('/:id', function(req, res, next) {
  model.findByIdAndRemove(req.params.id, req.body, function(err, user) {
    if (err) {
      res.json(buildErrorResponse(err));
    } else {
      res.json(user);
    }
  });
});

module.exports = router;
{'fraction_non_alphanumeric': 0.21467722289890379, 'fraction_numerical': 0.0, 'mean_word_length': 3.190051020408163, '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': '2679680', 'n_tokens_mistral': 1078, 'n_tokens_neox': 1057, 'n_words': 193}