<commit_before>'use strict';

var request           = require('request').defaults({jar: false}),
    qs                = require('querystring'),
    oauth             = {},
    appConfig         = require('../appConfig'),
    params;


var getCookie = function(headers){
  if(headers.jsessionid){
    var jsessionid = headers.jsessionid;
    console.log('jsessionid: ' + jsessionid);
  }
  if(headers.cookie){
    var cookies = headers.cookie;
    //console.log(cookies);
    var arrHead = cookies.indexOf('JSESSIONID=');
    var theCookieStart = cookies.substr(arrHead);
    var theCookieArray = theCookieStart.split(';');
    var theCookie = theCookieArray[0];
    return theCookie;
  }
};

// USER --------------------------------

exports.login = function(req, res, cookie){

  var uri = 'http://localhost:9000/user';
  console.log("--- LOGIN ---")
  console.log(req.data);
  console.log(req.body);
  var j = request.jar();
  var cookie = getCookie(req.headers);
  cookie = request.cookie(cookie);
  j.setCookie(cookie, uri);
  console.log("trying to get user with cookie " + cookie);
  request.get({url: uri, jar: j, form: req.body}, function (err, user){
    if (err) return handleError(res, err);
    res.status(200).json(JSON.parse(user.body));
  });
};

var saveUser = function(user, cookie, callback){
  var uri = 'http://localhost:9000/user';
  user.sessionToken = cookie;
  request.post(uri, {form: user}, function (err, res){
    callback(err, res.body);
  });
};

exports.register = function(req, res) {
  oauth.verifier = req.query.oauth_verifier;
  console.log(req.params);
  if (req.params.secret != 'ineba@123' || !req.params.name || !req.params.email || !req.params.password) {
    return res.redirect('/error');
  }<commit_msg>fixing errors<commit_after>'use strict';

var request           = require('request').defaults({jar: false}),
    qs                = require('querystring'),
    oauth             = {},
    appConfig         = require('../appConfig'),
    params;


var getCookie = function(headers){
  if(headers.jsessionid){
    var jsessionid = headers.jsessionid;
    console.log('jsessionid: ' + jsessionid);
  }
  if(headers.cookie){
    var cookies = headers.cookie;
    //console.log(cookies);
    var arrHead = cookies.indexOf('JSESSIONID=');
    var theCookieStart = cookies.substr(arrHead);
    var theCookieArray = theCookieStart.split(';');
    var theCookie = theCookieArray[0];
    return theCookie;
  }
};

// USER --------------------------------

exports.login = function(req, res, cookie){

  var uri = 'http://localhost:3000/user';
  console.log("--- LOGIN ---")
  console.log(req.data);
  console.log(req.body);
  var j = request.jar();
  var cookie = getCookie(req.headers);
  cookie = request.cookie(cookie);
  j.setCookie(cookie, uri);
  console.log("trying to get user with cookie " + cookie);
  request.get({url: uri, jar: j, form: req.body}, function (err, user){
    if (err) return handleError(res, err);
    res.status(200).json(JSON.parse(user.body));
  });
};

var saveUser = function(user, cookie, callback){
  var uri = 'http://localhost:3000/user';
  user.sessionToken = cookie;
  request.post(uri, {form: user}, function (err, res){
    if (err) return callback(err);
    callback(err, res.body);
  });
};

exports.register = function(req, res) {
  oauth.verifier = req.query.oauth_verifier;
  console.log(req.params);
  if (req.params.secret != 'ineba@123' || !req.params.name || !req.params.email || !req.params.password) {
    return res.redirect('/error');
  }
{'fraction_non_alphanumeric': 0.18447152167752903, 'fraction_numerical': 0.00850099178237461, 'mean_word_length': 3.1334894613583137, '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': '7188911', 'n_tokens_mistral': 1156, 'n_tokens_neox': 1126, 'n_words': 237}