<commit_before>// --------- Dependencies ---------
var User = require.main.require('./models/user');
var validator = require('validator');
require.main.require('./config/custom-validation.js')(validator);

module.exports = function(app, passport, isLoggedIn) {

    app.get('/connect/auth/youtube', isLoggedIn,
        passport.authenticate('youtube', {
            scope: [
                'https://www.googleapis.com/auth/youtube.force-ssl',
                'https://www.googleapis.com/auth/youtube.readonly'
            ]
    }));

    app.get('/connect/auth/youtube/callback', isLoggedIn,
        passport.authenticate('youtube', {
            failureRedirect: '/connect',
            successRedirect: '/connect'
    }));

    app.get('/setup/youtube/subscriptions', isLoggedIn, function(req, res) {
        User.setUpYouTubeSubs(req.user._id, function(err, allSubscriptions,
            existingSubscriptions) {
                // An error occurred
                if (err) {
                    req.flash('connectMessage', err.toString());
                    res.redirect('/connect');
                // Found subscriptions
                } else if (allSubscriptions &&
                    Object.keys(allSubscriptions).length > 0) {

                    // Fill in checkboxes for existing subscriptions
                    if (existingSubscriptions.length > 0) {
                        var subIds = [];
                        editingMode = true;

                        existingSubscriptions.forEach(function(subscription) {
                            subIds.push(subscription.subId);
                        });

                        for (var key in allSubscriptions) {
                            if (subIds.indexOf(allSubscriptions[key].id) > -1) {
                                allSubscriptions[key].checked = true;
                            } else {
                                allSubscriptions[key].checked = false;
                            }
                        }
                    }

                    res.render('youtube-setup', {
                        message: req.flash('setupMessage'),
                        content: allSubscriptions,
                        contentName: 'subscriptions'
                    });
                // No subscriptions found; return to connect page
                } else {
                    req.flash('connectMessage',
                        'You do not have any configurable YouTube ' +
                        'subscriptions groups at this time.');
                    res.redirect('/connect');
                }
            }<commit_msg>Fix message typo regarding no configurable YouTube subscriptions<commit_after>// --------- Dependencies ---------
var User = require.main.require('./models/user');
var validator = require('validator');
require.main.require('./config/custom-validation.js')(validator);

module.exports = function(app, passport, isLoggedIn) {

    app.get('/connect/auth/youtube', isLoggedIn,
        passport.authenticate('youtube', {
            scope: [
                'https://www.googleapis.com/auth/youtube.force-ssl',
                'https://www.googleapis.com/auth/youtube.readonly'
            ]
    }));

    app.get('/connect/auth/youtube/callback', isLoggedIn,
        passport.authenticate('youtube', {
            failureRedirect: '/connect',
            successRedirect: '/connect'
    }));

    app.get('/setup/youtube/subscriptions', isLoggedIn, function(req, res) {
        User.setUpYouTubeSubs(req.user._id, function(err, allSubscriptions,
            existingSubscriptions) {
                // An error occurred
                if (err) {
                    req.flash('connectMessage', err.toString());
                    res.redirect('/connect');
                // Found subscriptions
                } else if (allSubscriptions &&
                    Object.keys(allSubscriptions).length > 0) {

                    // Fill in checkboxes for existing subscriptions
                    if (existingSubscriptions.length > 0) {
                        var subIds = [];
                        editingMode = true;

                        existingSubscriptions.forEach(function(subscription) {
                            subIds.push(subscription.subId);
                        });

                        for (var key in allSubscriptions) {
                            if (subIds.indexOf(allSubscriptions[key].id) > -1) {
                                allSubscriptions[key].checked = true;
                            } else {
                                allSubscriptions[key].checked = false;
                            }
                        }
                    }

                    res.render('youtube-setup', {
                        message: req.flash('setupMessage'),
                        content: allSubscriptions,
                        contentName: 'subscriptions'
                    });
                // No subscriptions found; return to connect page
                } else {
                    req.flash('connectMessage',
                        'You do not have any configurable YouTube ' +
                        'subscriptions at this time.');
                    res.redirect('/connect');
                }
            }
{'fraction_non_alphanumeric': 0.11186696900982615, 'fraction_numerical': 0.0011337868480725624, 'mean_word_length': 1.2765591397849463, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 9, 'https://': 4, 'lorem ipsum': 0, 'www.': 4, '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': '1308679', 'n_tokens_mistral': 1244, 'n_tokens_neox': 1158, 'n_words': 218}