<commit_before>var express = require('express');
var router = express.Router();
var User = require('../models/user').User;

/* GET home page. */
router.get('/', function(req, res, next) {
 	console.log(req.session.user_id);
	res.render('index');
});

//registrar datos
router.get("/register",function(req,res){
  User.find(function(err,doc){
    console.log(doc);
    res.render("register");
  });
});
router.get("/login",function(req,res){
  res.render("login");
});
router.get('/',function(req,res){
  res.render('home/home')
});

//enviar datos del registro a la base de datos
router.post("/users",function(req,res){
  var user = new User({
    nombre: req.body.nombre,
    apellido: req.body.apellido,
    username: req.body.username,
    email: req.body.email,
    password: <PASSWORD>,
    password_confirmation: <PASSWORD>
  });
  if (user.password !== '')
    console.log('Se puede crear usuario');
  user.save(function(err){
    if(err){
      console.log(String(err));
    }
  if (user.password !== '')
    res.redirect("/home");
  else
    res.redirect("/register")
  });
});

//buscar usuario y enviar a la home
router.post("/sessions",function(req,res){
  User.findOne({username: req.body.username, password: <PASSWORD>},function(err,user){
      req.session.user_id = user._id;
      res.redirect("/home");

    });
  });

module.exports = router;<commit_msg>actualizacion<commit_after>var express = require('express');
var router = express.Router();
var User = require('../models/user').User;

/* GET home page. */
router.get('/', function(req, res, next) {
 	console.log(req.session.user_id);
	res.render('index');
});

//registrar datos
router.get("/register",function(req,res){
  User.find(function(err,doc){
    console.log(doc);
    res.render("register");
  });
});
router.get("/login",function(req,res){
  res.render("login");
});
router.get('/',function(req,res){
  res.render('./home/home')
});

//enviar datos del registro a la base de datos
router.post("/users",function(req,res){
  var user = new User({
    nombre: req.body.nombre,
    apellido: req.body.apellido,
    username: req.body.username,
    email: req.body.email,
    password: <PASSWORD>,
    password_confirmation: req.body.password_confirmation
  });
  if (user.password !== '')
    console.log('Se puede crear usuario');
  user.save(function(err){
    if(err){
      console.log(String(err));
    }
  if (user.password !== '')
    res.redirect("./home");
  else
    res.redirect("/register")
  });
});

//buscar usuario y enviar a la home
router.post("/sessions",function(req,res){
  User.findOne({username: req.body.username, password: <PASSWORD>},function(err,user){
      req.session.user_id = user._id;
      res.redirect("./home");

    });
  });

module.exports = router;
{'fraction_non_alphanumeric': 0.19927797833935018, 'fraction_numerical': 0.0, 'mean_word_length': 3.887125220458554, 'pattern_counts': {'":': 0, '<': 8, '<?xml version=': 0, '>': 8, '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': '6388031', 'n_tokens_mistral': 939, 'n_tokens_neox': 943, 'n_words': 169}