<commit_before>/// <reference path='../typings/tsd.d.ts' />
/// <reference path='../typings/express/express.d.ts' />
/// <reference path='../typings/express-session/express-session.d.ts' />
/// <reference path='../typings/express-validator/express-validator.d.ts' />
/// <reference path='../typings/express/express.ext.d.ts' />
/// <reference path='../typings/node/node.d.ts' />
/*jslint nomen: true */
'use strict';

import express = require("express");


var authenticationMiddleware : express.RequestHandler =  (req: express.Request, res: express.Response, next: Function) => {
    console.log('Request to: ' + req.url + " handled by auth middleware");
    var authenticated = req.session.authenticated;
    
    if(authenticated) {
        return next();
    }
    
    res.redirect('/login?url=' + req.url);
} 

module.exports = authenticationMiddleware;<commit_msg>Added JsDoc to authenticationMiddleware<commit_after>/// <reference path='../typings/tsd.d.ts' />
/// <reference path='../typings/express/express.d.ts' />
/// <reference path='../typings/express-session/express-session.d.ts' />
/// <reference path='../typings/express-validator/express-validator.d.ts' />
/// <reference path='../typings/express/express.ext.d.ts' />
/// <reference path='../typings/node/node.d.ts' />
/*jslint nomen: true */
'use strict';

import express = require("express");

/**
 * Express Middleware that redirects the client to the login url if they are not authenticated.
 * @param {Request} req - The current Express request.
 * @param {Response} res - The Express response.
 * @param {Function} next - Function to invoke the next middleware.
 **/
var authenticationMiddleware : express.RequestHandler =  (req: express.Request, res: express.Response, next: Function) => {
    console.log('Request to: ' + req.url + " handled by auth middleware");
    var authenticated = req.session.authenticated;
    
    if(authenticated) {
        return next();
    }
    
    res.redirect('/login?url=' + req.url);
} 

module.exports = authenticationMiddleware;
{'fraction_non_alphanumeric': 0.17906066536203522, 'fraction_numerical': 0.0, 'mean_word_length': 3.4168466522678185, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 17, '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': '3810811', 'n_tokens_mistral': 619, 'n_tokens_neox': 614, 'n_words': 133}