<commit_before>/**
 * GPII get token Handler
 *
 * Copyright 2014 Raising the Floor - International
 *
 * Licensed under the New BSD license. You may not use this file except in
 * compliance with this License.
 *
 * You may obtain a copy of the License at
 * https://github.com/gpii/universal/LICENSE.txt
 */

 /*global require*/

(function () {

    "use strict";
    
    var fluid = require("infusion")
    var gpii = fluid.registerNamespace("gpii");
    fluid.registerNamespace("gpii.request.flowManager");
    
    fluid.defaults("kettle.requests.request.handler.getToken", {
        gradeNames: ["gpii.request.flowManager.sessionAware", "autoInit"],
        invokers: {
            handle: {
                funcName: "gpii.request.flowManager.onGetToken",
                args: ["{that}", "{requestProxy}.events"
                ]
            }
        }
    });

    gpii.request.flowManager.onGetToken = function (that, events) {
        that.withSession(function (session, tokens) {
            var token = tokens.join(",");
            fluid.log("Reporting currently logged in user(s) as: " + token);
            events.onSuccess.fire(token);
        }, "No user currently logged into the system");
    };

})();<commit_msg>GPII-609: Return token(s) as JSON<commit_after>/**
 * GPII get token Handler
 *
 * Copyright 2014 Raising the Floor - International
 *
 * Licensed under the New BSD license. You may not use this file except in
 * compliance with this License.
 *
 * You may obtain a copy of the License at
 * https://github.com/gpii/universal/LICENSE.txt
 */

 /*global require*/

(function () {

    "use strict";
    
    var fluid = require("infusion");
    var gpii = fluid.registerNamespace("gpii");
    fluid.registerNamespace("gpii.request.flowManager");
    
    fluid.defaults("kettle.requests.request.handler.getToken", {
        gradeNames: ["gpii.request.flowManager.sessionAware", "autoInit"],
        invokers: {
            handle: {
                funcName: "gpii.request.flowManager.onGetToken",
                args: ["{that}", "{requestProxy}.events"
                ]
            }
        }
    });

    gpii.request.flowManager.onGetToken = function (that, events) {
        that.withSession(function (session, tokens) {
            len = tokens.length;
            if (len === 1) {
                token += '{"token": "' + tokens[0] + '"}';
            } else if (len > 1) {
                token = '[{"token": "' + tokens[0] + '"}'; 
                for (var i = 1; i < len; i++ ) {
                    token += ', {"token": "' + tokens[i] + '"}';
                }
                token += ']';
            }

            fluid.log("Reporting currently logged in user(s) as: " + token);
            events.onSuccess.fire(token);
        }, "No user currently logged into the system");
    };

})();
{'fraction_non_alphanumeric': 0.14175167077031306, 'fraction_numerical': 0.005627857896588111, 'mean_word_length': 2.0980392156862746, 'pattern_counts': {'":': 3, '<': 4, '<?xml version=': 0, '>': 4, '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': '6806403', 'n_tokens_mistral': 845, 'n_tokens_neox': 802, 'n_words': 201}