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

    app.use(function(req, res, next){
        //Look for the cookie
        console.log("ACCESS-TOKEN:" + req.cookies['access_token']);
        if(!req.cookies['access_token']){
            if(req.session.access_token){
                req.session.access_token = null;
            }
            return next();
        }
        console.log("Cached User:", req.session.user);
        if(req.session.access_token == req.cookies['access_token']){
            //No change of user => No need to load... hopefully
            res.bootstrap('user', new app.sdk.Account(req.session.user));

            return next();
        }
        app.sdk.Account.findByAccessToken(
            req.cookies['access_token'],
            { client_id: null, client_secret:null },//app.njax.config.core_app },
            function(err, account){
                if(err) return next(err);
                req.session.access_token = req.cookies['access_token'];

                req.session.user = account.toObject();
                res.bootstrap('user',  account);
                return next();
            }
        );

    });
}<commit_msg>Code flying from the fingertips<commit_after>
module.exports = function(app){

    app.use(function(req, res, next){
        //Look for the cookie
        //console.log("ACCESS-TOKEN:" + req.cookies['access_token']);
        if(!req.cookies['access_token']){
            if(req.session.access_token){
                req.session.access_token = null;
            }
            return next();
        }
        //console.log("Cached User:", req.session.user);
        if(req.session.access_token == req.cookies['access_token']){
            //No change of user => No need to load... hopefully
            res.bootstrap('user', new app.sdk.Account(req.session.user));

            return next();
        }
        app.sdk.Account.findByAccessToken(
            req.cookies['access_token'],
            { client_id: app.njax.config.core_app, client_secret:null },
            function(err, account){
                if(err) return next(err);
                req.session.access_token = req.cookies['access_token'];

                req.session.user = account.toObject();
                res.bootstrap('user',  account);
                return next();
            }
        );

    });
}
{'fraction_non_alphanumeric': 0.140485312899106, 'fraction_numerical': 0.0, 'mean_word_length': 1.8042959427207637, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, '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': '1325661', 'n_tokens_mistral': 660, 'n_tokens_neox': 638, 'n_words': 115}