<commit_before>(function(module) {
    "use strict";

    var User = module.parent.require('./user'),
        meta = module.parent.require('./meta'),
        db = module.parent.require('../src/database'),
        passport = module.parent.require('passport'),
        passportSoundcloud = require('passport-soundcloud').Strategy,
        fs = module.parent.require('fs'),
        path = module.parent.require('path'),
        nconf = module.parent.require('nconf');
    var constants = Object.freeze({
        'name': "Soundcloud Login",
        'admin': {
            'route': '/plugins/sso-soundcloud',
            'icon': 'fa-soundcloud'
        }
    });

    var Soundcloud = {};
    Soundcloud.init = function(app, middleware, controllers, callback) {
        function render(req, res, next) {
            res.render('admin/plugins/sso-soundcloud', {});
        }

        app.get('/admin/plugins/sso-soundcloud', middleware.admin.buildHeader, render);
        app.get('/api/admin/plugins/sso-soundcloud', render);
        callback();
    }

    Soundcloud.getStrategy = function(strategies, callback) {
        meta.settings.get('sso-soundcloud', function(err, settings) {
            if (!err && settings['id'] && settings['secret']) {
                passport.use(new passportSoundcloud({
                    clientID: settings['id'],
                    clientSecret: settings['secret'],
                    callbackURL: nconf.get('url') + '/auth/soundcloud/callback'
                }, function(accessToken, refreshToken, profile, done) {
                    console.log(profile);
                    Soundcloud.login(profile.id, profile.username, function(err, user) {
                        if (err) {
                            return done(err);
                        }
                        done(null, user);
                    });
                }));
                strategies.push({
                    name: 'soundcloud',
                    url: '/auth/soundcloud',
                    callbackURL: '/auth/soundcloud/callback',
                    icon: 'fa-soundcloud'
                });
            }
            callback(null, strategies);
        });
    };
    Soundcloud.login = function(soundcloudId, handle, email, callback) {
        Soundcloud.getUid(soundcloudId, function(err, uid) {
            if(err) {
                return callback(err);
            }
            if (uid !== null) {
// Existing User
                callback(null, {
                    uid: uid
                });
            } else {
// New User
                var success = function(uid) {
// Save soundcloud-specific information to the user
                    User.setUserField(uid, 'soundcloudId', soundcloudId);
                    db.setObjectField('soundcloudId:uid', soundcloudId, uid);
                    callback(null, {
                        uid: uid
                    });<commit_msg>logging again<commit_after>(function(module) {
    "use strict";

    var User = module.parent.require('./user'),
        meta = module.parent.require('./meta'),
        db = module.parent.require('../src/database'),
        passport = module.parent.require('passport'),
        passportSoundcloud = require('passport-soundcloud').Strategy,
        fs = module.parent.require('fs'),
        path = module.parent.require('path'),
        nconf = module.parent.require('nconf');
    var constants = Object.freeze({
        'name': "Soundcloud Login",
        'admin': {
            'route': '/plugins/sso-soundcloud',
            'icon': 'fa-soundcloud'
        }
    });

    var Soundcloud = {};
    Soundcloud.init = function(app, middleware, controllers, callback) {
        function render(req, res, next) {
            res.render('admin/plugins/sso-soundcloud', {});
        }

        app.get('/admin/plugins/sso-soundcloud', middleware.admin.buildHeader, render);
        app.get('/api/admin/plugins/sso-soundcloud', render);
        callback();
    }

    Soundcloud.getStrategy = function(strategies, callback) {
        meta.settings.get('sso-soundcloud', function(err, settings) {
            if (!err && settings['id'] && settings['secret']) {
                passport.use(new passportSoundcloud({
                    clientID: settings['id'],
                    clientSecret: settings['secret'],
                    callbackURL: nconf.get('url') + '/auth/soundcloud/callback'
                }, function(accessToken, refreshToken, profile, done) {
                    console.log(profile);
                    Soundcloud.login(profile.id, profile.username, function(err, user) {
                        if (err) {
                            console.log('error user info:', user)
                            return done(err);
                        }
                        console.log('success info:', user)
                        done(null, user);
                    });
                }));
                strategies.push({
                    name: 'soundcloud',
                    url: '/auth/soundcloud',
                    callbackURL: '/auth/soundcloud/callback',
                    icon: 'fa-soundcloud'
                });
            }
            callback(null, strategies);
        });
    };
    Soundcloud.login = function(soundcloudId, handle, email, callback) {
        Soundcloud.getUid(soundcloudId, function(err, uid) {
            if(err) {
                return callback(err);
            }
            if (uid !== null) {
// Existing User
                callback(null, {
                    uid: uid
                });
            } else {
// New User
                var success = function(uid) {
// Save soundcloud-specific information to the user
                    User.setUserField(uid, 'profile.id', soundcloudId);
                    db.setObjectField('profile.id:uid', soundcloudId, uid);
                    callback(null, {
                        uid: uid
                    });
{'fraction_non_alphanumeric': 0.13198992443324936, 'fraction_numerical': 0.0, 'mean_word_length': 1.5312367190820229, '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': '7501080', 'n_tokens_mistral': 1531, 'n_tokens_neox': 1467, 'n_words': 276}