<commit_before>const Router = require('express').Router;
const bodyParser = require('body-parser').json();
const basicHTTP = require(__dirname + '/../lib/basic_http');
const User = require(__dirname + '/../models/user');
const jwtAuth = require(__dirname + '/../lib/jwt_auth');

var authRouter = module.exports = exports = Router();

authRouter.post('/signup', bodyParser, (req, res) => {
  var password = req.body.password;
  req.body.password = <PASSWORD>;

  if (!password) return res.status(500).json({ msg: 'no blank passwords' });

  var newUser = new User(req.body);
  newUser.generateHash(password);
  password = <PASSWORD>;

  newUser.save((err, user) => {
    if (err) return res.status(500).json({ msg: 'could not create user' });

    user.generateToken((err, token) => {
      if (err) return res.status(500).json({ msg: 'could not generate token' });
      res.json({ token });
    });
  });
});<commit_msg>signin route<commit_after>const Router = require('express').Router;
const bodyParser = require('body-parser').json();
const basicHTTP = require(__dirname + '/../lib/basic_http');
const User = require(__dirname + '/../models/user');

var authRouter = module.exports = exports = Router();

authRouter.post('/signup', bodyParser, (req, res) => {
  var password = req.body.password;
  req.body.password = <PASSWORD>;

  if (!password) return res.status(500).json({ msg: 'no blank passwords' });

  var newUser = new User(req.body);
  newUser.generateHash(password);
  password = <PASSWORD>;

  newUser.save((err, user) => {
    if (err) return res.status(500).json({ msg: 'could not create user' });

    user.generateToken((err, token) => {
      if (err) return res.status(500).json({ msg: 'could not generate token' });
      res.json({ token });
    });
  });
});

authRouter.get('/signin', basicHTTP, (req, res) => {
  User.findOne({ username: req.auth.username }, (err, user) => {
    if (err) return res.status(500).json({ msg: 'database error' });
    if (!user) return res.status(500).json({ msg: 'user not found' });
    if (!user.compareHash(req.auth.password)) {
      return res.status(500).json({ msg: 'password error' });
    }

    user.generateToken((err, token) => {
      if (err) return res.status(500).json({ msg: 'could not generate token' });
      res.json({ token });
    });
  });
});
{'fraction_non_alphanumeric': 0.1929522990975505, 'fraction_numerical': 0.01289213579716373, 'mean_word_length': 3.8702928870292888, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 16, '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': '4473299', 'n_tokens_mistral': 758, 'n_tokens_neox': 726, 'n_words': 183}