'use strict';

var $ = require('jQuery');

function fetchSessionToken(cb, scope) {
    var dfd = $.Deferred();

    if (window.Kwf && window.Kwf.sessionToken) {
        dfd.resolve(window.Kwf.sessionToken);
        if (cb) cb.call(scope || window, window.Kwf.sessionToken);
    } else {
        $.ajax({
            method: "POST",
            url: "/kwf/user/login/json-get-session-token",
            dataType: "json"
        }).done(function(data) {
            window.Kwf.sessionToken = data.sessionToken;
            dfd.resolve(data.sessionToken);
            if (cb) cb.call(scope || window, data.sessionToken);
        }).fail(function(jqXHR, textStatus, errorThrown) {
            dfd.reject(jqXHR, textStatus, errorThrown);
        });
    }
    return dfd.promise();
};

module.exports = fetchSessionToken;

'use strict';

var $ = require('jQuery');

function fetchSessionToken(cb, scope) {
    var dfd = $.Deferred();

    if (window.Kwf && window.Kwf.sessionToken) {
        dfd.resolve(window.Kwf.sessionToken);
        if (cb) cb.call(scope || window, window.Kwf.sessionToken);
    } else {
        $.ajax({
            method: "POST",
            url: "/kwf/user/json-get-session-token",
            dataType: "json"
        }).done(function(data) {
            window.Kwf.sessionToken = data.sessionToken;
            dfd.resolve(data.sessionToken);
            if (cb) cb.call(scope || window, data.sessionToken);
        }).fail(function(jqXHR, textStatus, errorThrown) {
            dfd.reject(jqXHR, textStatus, errorThrown);
        });
    }
    return dfd.promise();
};

module.exports = fetchSessionToken;

--- 
+++ 
@@ -11,7 +11,7 @@
     } else {
         $.ajax({
             method: "POST",
-            url: "/kwf/user/json-get-session-token",
+            url: "/kwf/user/login/json-get-session-token",
             dataType: "json"
         }).done(function(data) {
             window.Kwf.sessionToken = data.sessionToken;
Correct the url for sessiontoken requests in fetchSessionToken()
