<commit_before>module.exports = {
  bind : function (app) {

    app.get('/', function (req, res) {
      // ALWAYS flush sessions if you're at the root index:
      req.session = null;
      res.render('index');
    });

    // add your routes here

    // V3 --------------------------------------------------------

    app.get('/v3/conveyancer/*', function(req, res, next) {

      var n = req.session.views || 0;
      req.session.views = ++n;
      console.log('views: ' + req.session.views);

      // To help. A list of all the session vars used:
      console.log('new_case: ' + req.session.new_case);
      console.log('case_reference: ' + req.session.case_reference);
      console.log('case_status: ' + req.session.case_status);
      console.log('property: ' + req.session.property);
      console.log('borrower_1: ' + req.session.borrower_1);
      console.log('borrower_2: ' + req.session.borrower_2);
      console.log('md_ref: ' + req.session.md_ref);
      console.log('mortgage_value: ' + req.session.mortgage_value);
      console.log('mortgage_charge: ' + req.session.mortgage_charge);
      console.log('deed_created: ' + req.session.deed_created);

      console.log('conveyancer_returns: ' + req.session.conveyancer_returns);

      console.log('completion_date: ' + req.session.completion_date);
      console.log('deed_signed: ' + req.session.deed_signed);
      console.log('applied: ' + req.session.applied);
      console.log('\n');

      next();
    });


    // CITIZEN --------------------

    // INTERCEPT the Verify prototype return page.
    // Redirect it to V3 IF APPROPRIATE.
    app.get('/v2/step4/step-2-identity-verified?requestId=sign-mortgage&action=sign-in', function (req, res, next) {
      var tokenVar = req.session.use_v3;
      if (typeof tokenVar === true) {
        res.redirect('v3/citizen/identity-verified');
      } else {
        next();
      }
    });

    // Make sure the "v3" var is TRUE on the V3 start page for the citizen.
    // This will activate the redirect above
    app.get('/v3/citizen', function(req, res) {
      req.session.use_v3 = true;
      res.render('v3/citizen/index');
    });

    // Make sure the "v3" var is FALSE on the V2 start page.
    // This will prvent the redirect above
    app.get('/v2/step4/step-1-citizen-signs-deed', function(req, res) {
      req.session.use_v3 = false;
      res.render('v2/step4/step-1-citizen-signs-deed');
    });


    // Unhappy path catcher
    app.get('/deed-journeys/deed-transaction/*', function(req, res, next) {
      var answer = req.query['radio-inline-group'];
      if (answer === 'No') {
        res.redirect('/deed-journeys/deed-transaction/unhappy-path');
      } else {
        next();
      }
    });
<commit_msg>Session fail, redirect fail<commit_after>module.exports = {
  bind : function (app) {

    app.get('/', function (req, res) {
      // ALWAYS flush sessions if you're at the root index:
      req.session = null;
      res.render('index');
    });

    // add your routes here

    // V3 --------------------------------------------------------

    app.get('/v3/conveyancer/*', function(req, res, next) {

      var n = req.session.views || 0;
      req.session.views = ++n;
      console.log('views: ' + req.session.views);

      // To help. A list of all the session vars used:
      console.log('new_case: ' + req.session.new_case);
      console.log('case_reference: ' + req.session.case_reference);
      console.log('case_status: ' + req.session.case_status);
      console.log('property: ' + req.session.property);
      console.log('borrower_1: ' + req.session.borrower_1);
      console.log('borrower_2: ' + req.session.borrower_2);
      console.log('md_ref: ' + req.session.md_ref);
      console.log('mortgage_value: ' + req.session.mortgage_value);
      console.log('mortgage_charge: ' + req.session.mortgage_charge);
      console.log('deed_created: ' + req.session.deed_created);

      console.log('conveyancer_returns: ' + req.session.conveyancer_returns);

      console.log('completion_date: ' + req.session.completion_date);
      console.log('deed_signed: ' + req.session.deed_signed);
      console.log('applied: ' + req.session.applied);
      console.log('\n');

      next();
    });


    // CITIZEN --------------------

    // Unhappy path catcher
    app.get('/deed-journeys/deed-transaction/*', function(req, res, next) {
      var answer = req.query['radio-inline-group'];
      if (answer === 'No') {
        res.redirect('/deed-journeys/deed-transaction/unhappy-path');
      } else {
        next();
      }
    });

{'fraction_non_alphanumeric': 0.18805646036916396, 'fraction_numerical': 0.00738327904451683, 'mean_word_length': 2.357142857142857, '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': '708587', 'n_tokens_mistral': 1521, 'n_tokens_neox': 1447, 'n_words': 269}