<commit_before>var endOfLine = require('os').EOL;
var config = require("./configuration");
var octokitWrapper = require("./octokit");

var lockedRegex = new RegExp("number of login attempts exceeded", "gi");
var twoFactorRegex = new RegExp("must specify two-factor authentication otp code", "gi");
var badCredentialsRegex = new RegExp("bad credentials", "gi");

var scopes = ["user", "repo", "gist", "write:public_key"];

var handleAuthentication = function (username, password, onSuccess, onFailure, twoFactor) {
    var octokit = octokitWrapper.createOctokit();

    octokit.authenticate({
        type: "basic",
        username: username,
        password: password
    });

    var headers;
    if (twoFactor) {
        headers = {
            "X-GitHub-OTP": twoFactor
        };
    }

    octokit.authorization.create({
        scopes: scopes,
        note: config.appName,
        client_id: config.clientId,
        client_secret: config.clientSecret,
        headers: headers
    }, function (err, res) {

        console.log("octokit.authorization.create", typeof(err), err, res);
        if (err) {
            if (twoFactor && err.code && err.code === 422) {
                //Two Factor Enterprise workaround
                onSuccess(password);
            }
            else if (twoFactorRegex.test(err.message)) {
                onSuccess(password, "<PASSWORD>");<commit_msg>Removing unintentional console log<commit_after>var endOfLine = require('os').EOL;
var config = require("./configuration");
var octokitWrapper = require("./octokit");

var lockedRegex = new RegExp("number of login attempts exceeded", "gi");
var twoFactorRegex = new RegExp("must specify two-factor authentication otp code", "gi");
var badCredentialsRegex = new RegExp("bad credentials", "gi");

var scopes = ["user", "repo", "gist", "write:public_key"];

var handleAuthentication = function (username, password, onSuccess, onFailure, twoFactor) {
    var octokit = octokitWrapper.createOctokit();

    octokit.authenticate({
        type: "basic",
        username: username,
        password: password
    });

    var headers;
    if (twoFactor) {
        headers = {
            "X-GitHub-OTP": twoFactor
        };
    }

    octokit.authorization.create({
        scopes: scopes,
        note: config.appName,
        client_id: config.clientId,
        client_secret: config.clientSecret,
        headers: headers
    }, function (err, res) {
        if (err) {
            if (twoFactor && err.code && err.code === 422) {
                //Two Factor Enterprise workaround
                onSuccess(password);
            }
            else if (twoFactorRegex.test(err.message)) {
                onSuccess(password, "<PASSWORD>");
{'fraction_non_alphanumeric': 0.12774524158125916, 'fraction_numerical': 0.0021961932650073207, 'mean_word_length': 2.663538873994638, 'pattern_counts': {'":': 2, '<': 5, '<?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': '97818', 'n_tokens_mistral': 789, 'n_tokens_neox': 760, 'n_words': 198}