<commit_before>'use strict';

/**
 * Controller for all registration routes and functions.
 */

const co = require('co');
const _ = require('lodash');

const passport = requireLocal('services/auth');
const session = requireLocal('controller/session');
const api = requireLocal('services/api-proxy');

/**
 * All available URLs for redirecting the user.
 * @type {*}
 */
const URLS = {
  LOGIN: '/login',
  REGISTER: '/register',
  PARTICIPANT: '/participant',
  SPONSOR: '/sponsor',
  SELECTION: '/selection',
  TEAM: '/team-create',
  INVITE: '/team-invite',
  TEAM_SUCCESS: '/team-success',
  INVITE_SUCCESS: '/invite-success',
  SPONSOR_SUCCESS: '/sponsor-success'
};

let registration = {};

/**
 * Sends the occurred error back to the client, and logs it to the bunyan global logger.
 * @param res
 * @param errMsg
 * @param err
 * @returns {*}
 */
const sendErr = (res, errMsg, err) => {

  if (err) logger.error(errMsg, err);
  else logger.error(errMsg);

  res.status(500).send({error: errMsg});
};

/**
 * Timebased closing of registration
 * @param req
 * @param res
 * @param next
 */

registration.lock = (req, res, next) => {
  if(Date.now() > 1463454000000) {
    return res.redirect('/closed')
  }
  next();
};

/**
 * POST route for /register
 * @param req
 * @param res<commit_msg>sets time for registration closing to 9:00 GMT+2<commit_after>'use strict';

/**
 * Controller for all registration routes and functions.
 */

const co = require('co');
const _ = require('lodash');

const passport = requireLocal('services/auth');
const session = requireLocal('controller/session');
const api = requireLocal('services/api-proxy');

/**
 * All available URLs for redirecting the user.
 * @type {*}
 */
const URLS = {
  LOGIN: '/login',
  REGISTER: '/register',
  PARTICIPANT: '/participant',
  SPONSOR: '/sponsor',
  SELECTION: '/selection',
  TEAM: '/team-create',
  INVITE: '/team-invite',
  TEAM_SUCCESS: '/team-success',
  INVITE_SUCCESS: '/invite-success',
  SPONSOR_SUCCESS: '/sponsor-success'
};

let registration = {};

/**
 * Sends the occurred error back to the client, and logs it to the bunyan global logger.
 * @param res
 * @param errMsg
 * @param err
 * @returns {*}
 */
const sendErr = (res, errMsg, err) => {

  if (err) logger.error(errMsg, err);
  else logger.error(errMsg);

  res.status(500).send({error: errMsg});
};

/**
 * Timebased closing of registration
 * @param req
 * @param res
 * @param next
 */

registration.lock = (req, res, next) => {
  if(Date.now() > 1463468400000) {
    return res.redirect('/closed')
  }
  next();
};

/**
 * POST route for /register
 * @param req
 * @param res
{'fraction_non_alphanumeric': 0.16799695933105283, 'fraction_numerical': 0.013683010262257697, 'mean_word_length': 3.7854545454545456, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 9, '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': '1875198', 'n_tokens_mistral': 913, 'n_tokens_neox': 862, 'n_words': 242}