<commit_before>var fs = require('fs'),
    _ = require('lodash'),
    mongoose = require('mongoose'),
    passport = require('passport'),
    GitlabStrategy = require('passport-gitlab').Strategy;

function Gitlab(options, core) {
    this.options = options;
    this.core = core;
    this.key = 'gitlab';

    this.setup = this.setup.bind(this);
    this.getGitlabStrategy = this.getGitlabStrategy.bind(this);
}

Gitlab.defaults = {
    gitlabURL: 'https://gitlab.com'
};

Gitlab.key = 'gitlab';

Gitlab.prototype.setup = function() {
    passport.use(this.getGitlabStrategy());
};

Gitlab.prototype.authenticate = function(req, res, cb) {
    passport.authenticate('gitlab', cb)(req, res);
};

Gitlab.prototype.getGitlabStrategy = function() {
    return new GitlabStrategy(
        {
            clientID: this.options.clientID,
            clientSecret: this.options.clientSecret,
            gitlabURL: this.options.gitlabURL,
            callbackURL: this.options.callbackURL,
        },
        function (accessToken, refreshToken, user, done) {
            return Gitlab.findOrCreate(this.core, user, done);
        }.bind(this)
    );
};

Gitlab.findOrCreate = function(core, gitlabUser, callback) {<commit_msg>Check for response and fail if not present<commit_after>var fs = require('fs'),
    _ = require('lodash'),
    mongoose = require('mongoose'),
    passport = require('passport'),
    GitlabStrategy = require('passport-gitlab').Strategy;

function Gitlab(options, core) {
    this.options = options;
    this.core = core;
    this.key = 'gitlab';

    this.setup = this.setup.bind(this);
    this.getGitlabStrategy = this.getGitlabStrategy.bind(this);
}

Gitlab.defaults = {
    gitlabURL: 'https://gitlab.com'
};

Gitlab.key = 'gitlab';

Gitlab.prototype.setup = function() {
    passport.use(this.getGitlabStrategy());
};

Gitlab.prototype.authenticate = function(req, res, cb) {
    if (!res) {
        return cb(null, null);
    }

    passport.authenticate('gitlab', cb)(req, res);
};

Gitlab.prototype.getGitlabStrategy = function() {
    return new GitlabStrategy(
        {
            clientID: this.options.clientID,
            clientSecret: this.options.clientSecret,
            gitlabURL: this.options.gitlabURL,
            callbackURL: this.options.callbackURL,
        },
        function (accessToken, refreshToken, user, done) {
            return Gitlab.findOrCreate(this.core, user, done);
        }.bind(this)
    );
};

Gitlab.findOrCreate = function(core, gitlabUser, callback) {
{'fraction_non_alphanumeric': 0.13923046410154702, 'fraction_numerical': 0.0, 'mean_word_length': 3.134426229508197, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 2, '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': '558616', 'n_tokens_mistral': 814, 'n_tokens_neox': 786, 'n_words': 142}