<commit_before>var async = require('async'),
    _ = require('lodash');

var passport = require('passport'),
    GitHubStrategy = require('passport-github').Strategy;

var credentials = {
    clientID: process.env.GITHUB_CLIENT_ID,
    clientSecret: process.env.GITHUB_CLIENT_SECRET,
    callbackURL: process.env.GITHUB_CALLBACK_URL,
    scope: ['user'],
    userAgent: 'Octocat'
};

exports.authenticateUser = function(req, res, next) {
    // Initalize GitHub credentials
    var ghStrategy = new GitHubStrategy(credentials, function(accessToken, refreshToken, profile, done) {
        console.log(profile);
        done(null, {
            accessToken: accessToken,
            refreshToken: refreshToken,
            profile: profile
        });
    });
    // Pass through authentication to passport
    passport.use(ghStrategy);
    // Save user data once returning from GitHub
    if (_.has(req.query, 'cb')) {
        passport.authenticate('github', function(err, data, info) {
            if (err || !data) {
                return res.redirect('/signin');
            }
            var name = data.profile && data.profile.displayName ? data.profile.displayName.split(' ') : [];
            var auth = {
                type: 'github',
                name: {
					first: name.length ? name[0] : '',
					last: name.length > 1 ? name[1] : ''
				},
                profileId: data.profile.id,
                accessToken: data.accessToken,
				refreshToken: data.refreshToken,
                username: data.profile.username
            };
            req.session.auth = auth;
            return res.redirect('/auth/confirm');
        })(req, res, next);
    } else {
        passport.authenticate('github')(req, res, next);
    }
};<commit_msg>fix github<commit_after>var async = require('async'),
    _ = require('lodash');

var passport = require('passport'),
    GitHubStrategy = require('passport-github').Strategy;

var credentials = {
    clientID: process.env.GITHUB_CLIENT_ID,
    clientSecret: process.env.GITHUB_CLIENT_SECRET,
    callbackURL: process.env.GITHUB_CALLBACK_URL,
    scope: ['user'],
    userAgent: 'Octocat'
};

exports.authenticateUser = function(req, res, next) {
    // Initalize GitHub credentials
    var ghStrategy = new GitHubStrategy(credentials, function(accessToken, refreshToken, profile, done) {
        console.log(profile);
        done(null, {
            accessToken: accessToken,
            refreshToken: refreshToken,
            profile: profile
        });
    });
    // Pass through authentication to passport
    passport.use(ghStrategy);
    // Save user data once returning from GitHub
    if (_.has(req.query, 'cb')) {
        passport.authenticate('github', {session: false}, function(err, data, info) {
            if (err || !data) {
                return res.redirect('/signin');
            }
            var name = data.profile && data.profile.displayName ? data.profile.displayName.split(' ') : [];
            var auth = {
                type: 'github',
                name: {
					first: name.length ? name[0] : '',
					last: name.length > 1 ? name[1] : ''
				},
                profileId: data.profile.id,
                accessToken: data.accessToken,
				refreshToken: data.refreshToken,
                username: data.profile.username
            };
            req.session.auth = auth;
            return res.redirect('/auth/confirm');
        })(req, res, next);
    } else {
        passport.authenticate('github')(req, res, next);
    }
};
{'fraction_non_alphanumeric': 0.13000283848992336, 'fraction_numerical': 0.0017030939540164632, 'mean_word_length': 2.2449355432780846, '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': '6049848', 'n_tokens_mistral': 1042, 'n_tokens_neox': 980, 'n_words': 213}