<commit_before>var express = require('express'),
    http    = require('http'),
    path    = require('path'),
    pg      = require('pg'),
    db      = require('./db'),
    User    = require('./models/user'),
    crypto  = require('crypto'),
		uuid    = require('uuid');

var app = express();
app.set('port', process.env.PORT || 3000);
app.use(express.favicon())
app.use(express.bodyParser())
app.use(express.methodOverride())
app.use(express.static(path.join(__dirname, 'public')))

app.get('/users', function(req, res) {
	User.all().success(function(users) {
    res.send(users);
	});
})

app.post('/users', function(req, res) {
  if (req.body.name && req.body.password) {
		var salt = generateSalt();
		var passwordHash = saltPassword(req.body.password, salt);

    var user = User.build({
			id : uuid.v4(),
			name: req.body.name,
  	  salt: salt,
 			passwordHash: <PASSWORD>
    });

		user.save()
		.success(function() {
			res.send({ status: 'user created' })
		})
		.error(function(err) {
			res.send({ status: 'user not created', error: err });
		});
  } else {
	  res.send({
		  error: 'required params: name, password'
		});
  }
});

// login with name, password
app.post('/sessions', function(req, res) {
  if (req.body.name && req.body.password) {
    User.findAll({ where: { name: req.body.name }})
    .error(function(err){
			res.send({ error: 'user not found' });
    })
		.success(function(results){
			user = results[0];
			if (user) {
				var valid = verifyPassword(
					req.body.password, 
					user.salt, 
					user.passwordHash<commit_msg>[CHORE] Return user when created<commit_after>var express = require('express'),
    http    = require('http'),
    path    = require('path'),
    pg      = require('pg'),
    db      = require('./db'),
    User    = require('./models/user'),
    crypto  = require('crypto'),
		uuid    = require('uuid');

var app = express();
app.set('port', process.env.PORT || 3000);
app.use(express.favicon())
app.use(express.bodyParser())
app.use(express.methodOverride())
app.use(express.static(path.join(__dirname, 'public')))

app.get('/users', function(req, res) {
	User.all().success(function(users) {
    res.send(users);
	});
})

app.post('/users', function(req, res) {
  if (req.body.name && req.body.password) {
		var salt = generateSalt();
		var passwordHash = saltPassword(req.body.password, salt);

    var user = User.build({
			id : uuid.v4(),
			name: req.body.name,
  	  salt: salt,
 			passwordHash: passwordHash
    });

		user.save()
		.success(function() {
			res.send({ status: 'user created', user: user })
		})
		.error(function(err) {
			res.send({ status: 'user not created', error: err });
		});
  } else {
	  res.send({
		  error: 'required params: name, password'
		});
  }
});

app.post('/sessions', function(req, res) {
  if (req.body.name && req.body.password) {
    User.findAll({ where: { name: req.body.name }})
    .error(function(err){
			res.send({ error: 'user not found' });
    })
		.success(function(results){
			user = results[0];
			if (user) {
				var valid = verifyPassword(
					req.body.password, 
					user.salt, 
					user.passwordHash
{'fraction_non_alphanumeric': 0.1921606118546845, 'fraction_numerical': 0.0038240917782026767, 'mean_word_length': 3.1853333333333333, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 4, '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': '4567691', 'n_tokens_mistral': 1165, 'n_tokens_neox': 1058, 'n_words': 219}