<commit_before>'use strict';

var utils = require('../lib/utils');
var config = require('../config');
var dbUtils = require('../lib/dbUtils');
var exports = module.exports = utils.requireDir(__dirname);




// var middleware = require('../middleware');

var passport = require('passport');
var permission = require('permission');



// Domain Specific Routes
var newProfileRoutes = require('./newprofile');
var profileRoutes = require('./profile');
var messagingRoutes = require('./privatemessage');
var inboxRoutes = require('./inbox');

exports.createAllRoutes = createAllRoutes;
exports.createErrorHandling = createErrorHandling;

function createAllRoutes(router) {

    router.get('/', render('home'));

    router.get('/login', redirectToProfile, render('login'));


    router.post('/auth', passport.authenticate('local', {
        successRedirect: '/inbox', // redirect to the secure profile section
        failureRedirect: '/login', // redirect back to the signup page if there is an error
        failureFlash: true // allow flash messages
    }));



    router.get('/logout',
        function (req, res) {
            req.logout();
            res.redirect('/');
        });

    // testing session
    router.get('/session', function (req, res) {
        var n = req.session.views || 0
        req.session.views = ++n
        res.end(n + ' views')
    });

    newProfileRoutes.createNewProfiles(router);
    messagingRoutes.processMessages(router);
    messagingRoutes.getMessageData(router);
    profileRoutes.init(router);
    inboxRoutes.init(router);


}

function redirectToProfile(req, res, next) {
    if (req.user) {
        res.redirect('/profile');<commit_msg>added route to get user details<commit_after>'use strict';

var utils = require('../lib/utils');
var config = require('../config');
var dbUtils = require('../lib/dbUtils');
var exports = module.exports = utils.requireDir(__dirname);

// var middleware = require('../middleware');

var passport = require('passport');
var permission = require('permission');

// Domain Specific Routes
var newProfileRoutes = require('./newprofile');
var profileRoutes = require('./profile');
var messagingRoutes = require('./privatemessage');
var dbCalls = require('./dbCalls');
var inboxRoutes = require('./inbox');

exports.createAllRoutes = createAllRoutes;
exports.createErrorHandling = createErrorHandling;

function createAllRoutes(router) {

    router.get('/', render('home'));

    router.get('/login', redirectToProfile, render('login'));


    router.post('/auth', passport.authenticate('local', {
        successRedirect: '/inbox', // redirect to the secure profile section
        failureRedirect: '/login', // redirect back to the signup page if there is an error
        failureFlash: true // allow flash messages
    }));



    router.get('/logout',
        function (req, res) {
            req.logout();
            res.redirect('/');
        });

    // testing session
    router.get('/session', function (req, res) {
        var n = req.session.views || 0
        req.session.views = ++n
        res.end(n + ' views')
    });

    newProfileRoutes.createNewProfiles(router);
    messagingRoutes.processMessages(router);
    messagingRoutes.getMessageData(router);
    profileRoutes.init(router);
    inboxRoutes.init(router);
    dbCalls.init(router);

}

function redirectToProfile(req, res, next) {
    if (req.user) {
        res.redirect('/profile');
{'fraction_non_alphanumeric': 0.15339918651946544, 'fraction_numerical': 0.0005810575246949448, 'mean_word_length': 3.391581632653061, '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': '4961832', 'n_tokens_mistral': 984, 'n_tokens_neox': 951, 'n_words': 228}