<commit_before>'use strict';
const express      = require('express');
const router       = express.Router();
const request      = require('request');
const jwt          = require('jwt-simple');
const qs           = require('querystring');
const User         = require('../models/User');
const moment       = require('moment');

/**
 * Save new user to db and give them a signed jwt token
 */
 function createJWT(user) {
   var payload = {
     sub: user._id,
     iat: moment().unix(),
     exp: moment().add(14, 'days').unix()
   };
   return jwt.encode(payload, process.env.TOKEN_SECRET);
 }

router.post('/signup', function(req, res) {
  User.findOne({ email: req.body.email }, function(err, existingUser) {
    if (existingUser) {
      return res.status(409).send({ message: 'Email is already taken' });
    }

    var user = new User({
      displayName: req.body.displayName,
      email: req.body.email,
      password: <PASSWORD>
    });
    console.log(user);
    user.save(function(err, result) {
      if (err) {
        res.status(500).send({ message: err.message });
      }
      console.log('RESULT',result);
      res.send({ token: createJWT(result) });
    });
  });
});

/**
 * Regular login for a user register with methods above
 * Using the +password param to tell mongo to include in query
 */

router.post('/login', function(req, res) {
  User.findOne({ email: req.body.email }, '+password', function(err, user) {
    if (!user) {
      return res.status(401).send({ message: 'Invalid email and/or password' });
    }
    user.comparePassword(req.body.password, function(err, isMatch) {
      if (!isMatch) {
        return res.status(401).send({ message: 'Invalid email and/or password' });
      }
      res.send({ token: createJWT(user) });
    });
  });
});

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

  var requestTokenUrl = process.env.REQ_TOKEN_URL;
  var accessTokenUrl = process.env.ACC_TOKEN_URL;
  var profileUrl = process.env.PROF_URL;

  if (!req.body.oauth_token || !req.body.oauth_verifier) {<commit_msg>remove console.log<commit_after>'use strict';
const express      = require('express');
const router       = express.Router();
const request      = require('request');
const jwt          = require('jwt-simple');
const qs           = require('querystring');
const User         = require('../models/User');
const moment       = require('moment');

/**
 * Save new user to db and give them a signed jwt token
 */
 function createJWT(user) {
   var payload = {
     sub: user._id,
     iat: moment().unix(),
     exp: moment().add(14, 'days').unix()
   };
   return jwt.encode(payload, process.env.TOKEN_SECRET);
 }

router.post('/signup', function(req, res) {
  User.findOne({ email: req.body.email }, function(err, existingUser) {
    if (existingUser) {
      return res.status(409).send({ message: 'Email is already taken' });
    }

    var user = new User({
      displayName: req.body.displayName,
      email: req.body.email,
      password: <PASSWORD>
    });
    user.save(function(err, result) {
      if (err) {
        res.status(500).send({ message: err.message });
      }
      res.send({ token: createJWT(result) });
    });
  });
});

/**
 * Regular login for a user register with methods above
 * Using the +password param to tell mongo to include in query
 */

router.post('/login', function(req, res) {
  User.findOne({ email: req.body.email }, '+password', function(err, user) {
    if (!user) {
      return res.status(401).send({ message: 'Invalid email and/or password' });
    }
    user.comparePassword(req.body.password, function(err, isMatch) {
      if (!isMatch) {
        return res.status(401).send({ message: 'Invalid email and/or password' });
      }
      res.send({ token: createJWT(user) });
    });
  });
});

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

  var requestTokenUrl = process.env.REQ_TOKEN_URL;
  var accessTokenUrl = process.env.ACC_TOKEN_URL;
  var profileUrl = process.env.PROF_URL;

  if (!req.body.oauth_token || !req.body.oauth_verifier) {
{'fraction_non_alphanumeric': 0.16097077761267956, 'fraction_numerical': 0.006934125804853888, 'mean_word_length': 3.018905472636816, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '1174513', 'n_tokens_mistral': 1288, 'n_tokens_neox': 1263, 'n_words': 311}