<commit_before>"use strict";

// Imports.
import passport from 'passport'
import util from 'util'

// Define strategy.
let HttpStrategy = function (auth) {
    this.name = 'http';
    this.authentication = auth;

    passport.Strategy.call(this);
};

// Inherit basic strategy.
util.inherits(HttpStrategy, passport.Strategy);

// Define auth method.
HttpStrategy.prototype.authenticate = function (req) {
    let self = this;

    // Is auth.
    this.authentication.isAuthenticated(req, function (result) {
        if (result instanceof Error) {
            self.error(result);
        } else if (!result.user) {
            let header = self.authentication.generateHeader(result);
            self.fail(header);
        } else {
            self.success(result.user);
        }
    });
};

// Export.
export function strategy(auth) {
    return new HttpStrategy(auth);
}<commit_msg>Fixing passport integration.<commit_after>"use strict";

// Imports.
import passport from 'passport'
import util from 'util'

// Define strategy.
let HttpStrategy = function (auth) {
    this.name = 'http';
    this.authentication = auth;

    passport.Strategy.call(this);
};

// Inherit basic strategy.
util.inherits(HttpStrategy, passport.Strategy);

// Define auth method.
HttpStrategy.prototype.authenticate = function (req) {
    let self = this;

    // Is auth.
    this.authentication.isAuthenticated(req, function (result) {
        if (result instanceof Error) {
            self.error(result);
        } else if (!result.pass) {
            let header = self.authentication.generateHeader(result);
            self.fail(header);
        } else {
            self.success(result.user);
        }
    });
};

// Export.
export function strategy(auth) {
    return new HttpStrategy(auth);
}
{'fraction_non_alphanumeric': 0.1250701065619742, 'fraction_numerical': 0.0, 'mean_word_length': 2.6707818930041154, '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': '4001497', 'n_tokens_mistral': 521, 'n_tokens_neox': 506, 'n_words': 126}