<commit_before>// Given a Hapi server, connect to redis using the hapi-redis plugin
// Then run a callback (optional)
// The node_redis redis client object instance will be stored here: server.plugins['hapi-redis'].client

// PLUGIN code - consider moving elsewhere if necessary

var authPlug = {
  register: function(plugin, options, next) {
    plugin.auth.scheme('seelio_auth', function( server, options) {
      return {
        authenticate: function(request, reply) {
          options.authenticate(request, function(err, credentialsObj) {
            if (err) {
              return reply(err, null, {});
            }
            else {
              return reply.continue({credentials: credentialsObj});
            }
          });
        }
      }
    });
    next();
  }
};

authPlug.register.attributes = {
  name: 'seelioPlugin',
  version: '0.0.1'
};

// END PLUGIN code


function connectHapiServerToRedis (server, cb) {
  // Register Plugin - inside redis-session-reader, in the connectHapiServerToRedis.js file
  server.register(authPlug, function(err) {
    console.log('REGISTERING PLUGIN');
    server.auth.strategy('my_auth',  'seelio_auth', {
      authenticate: function(req, cb) {
		  
        // Get cookie id
		
        // Call redis with cookie to get session
		
        // From session get userid
        var rawSid = req.state['connect.sid.1.0'];
 
        var sid = RedisSessionReader.unsignCookieSid(rawSid, secret);
        //RedisSessionReader.getSessionIdFromRedis(sessionId, server.plugins['hapi-redis'].client, function (err, userId) {
        //  if (err) {return cb(err);}
        //  cb(null, { userId: userId })
        //});		  <commit_msg>Commented out Redis line during testing<commit_after>// Given a Hapi server, connect to redis using the hapi-redis plugin
// Then run a callback (optional)
// The node_redis redis client object instance will be stored here: server.plugins['hapi-redis'].client

// PLUGIN code - consider moving elsewhere if necessary

var authPlug = {
  register: function(plugin, options, next) {
    plugin.auth.scheme('seelio_auth', function( server, options) {
      return {
        authenticate: function(request, reply) {
          options.authenticate(request, function(err, credentialsObj) {
            if (err) {
              return reply(err, null, {});
            }
            else {
              return reply.continue({credentials: credentialsObj});
            }
          });
        }
      }
    });
    next();
  }
};

authPlug.register.attributes = {
  name: 'seelioPlugin',
  version: '0.0.1'
};

// END PLUGIN code


function connectHapiServerToRedis (server, cb) {
  // Register Plugin - inside redis-session-reader, in the connectHapiServerToRedis.js file
  server.register(authPlug, function(err) {
    console.log('REGISTERING PLUGIN');
    server.auth.strategy('my_auth',  'seelio_auth', {
      authenticate: function(req, cb) {
		  
        // Get cookie id
		
        // Call redis with cookie to get session
		
        // From session get userid
        var rawSid = req.state['connect.sid.1.0'];
 
        //var sid = RedisSessionReader.unsignCookieSid(rawSid, secret);
        //RedisSessionReader.getSessionIdFromRedis(sessionId, server.plugins['hapi-redis'].client, function (err, userId) {
        //  if (err) {return cb(err);}
        //  cb(null, { userId: userId })
        //});		  
{'fraction_non_alphanumeric': 0.1214622641509434, 'fraction_numerical': 0.00294811320754717, 'mean_word_length': 2.490740740740741, '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': '2623364', 'n_tokens_mistral': 1039, 'n_tokens_neox': 1010, 'n_words': 253}