<commit_before>var debug = require('debug')('authentication:mailer');

exports = module.exports = function (config) {
    var templates = require('./templates')(config.get('service.name'));
    var email, sender, title, verificationRoute;

    if (config.get('env') === 'production') {
        email = require('mandrill-send')(config.get('mandrill.api.key'));
        sender = config.get('mandrill.sender');
        verificationRoute = config.get('email.verification.route');

        return function (user, provider, action, token) {
            email({
                from: sender,
                to: [user.email],
                subject: templates[provider][action].title(),
                html: templates[provider][action].message(user.fullname, verificationRoute, token)
            }, function (err) {
                if (err) return debug(err);
                if (token) debug('token: ' + token);
                debug('successfully sent email for action: ' + action + ' for provider: ' + provider + ' to user via email: ' + user.email);
            });
        };
    }
    else {
        return function (user, provider, action, token) {
            debug(templates[provider][action](user.fullname, verificationRoute, token));
        };
    }
};<commit_msg>fix small bug when using mailer in development mode<commit_after>var debug = require('debug')('express-passport-app:mailer');

exports = module.exports = function (config) {
    var templates = require('./templates')(config.get('service.name'));
    var email, sender, title, verificationRoute;

    if (config.get('env') === 'production') {
        email = require('mandrill-send')(config.get('mandrill.api.key'));
        sender = config.get('mandrill.sender');
        verificationRoute = config.get('email.verification.route');

        return function (user, provider, action, token) {
            email({
                from: sender,
                to: [user.email],
                subject: templates[provider][action].title(),
                html: templates[provider][action].message(user.fullname, verificationRoute, token)
            }, function (err) {
                if (err) return debug(err);
                if (token) debug('token: ' + token);
                debug('successfully sent email for action: ' + action + ' for provider: ' + provider + ' to user via email: ' + user.email);
            });
        };
    }
    else {
        return function (user, provider, action, token) {
            debug(templates[provider][action].message(user.fullname, verificationRoute, token));
        };
    }
};
{'fraction_non_alphanumeric': 0.14599383667180277, 'fraction_numerical': 0.0, 'mean_word_length': 2.444297082228117, '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': '1271830', 'n_tokens_mistral': 684, 'n_tokens_neox': 661, 'n_words': 158}