(function() {
    var t = klp.auth = {};
    var tokenKey = "klpUserToken";
    var emailKey = "klpUserEmail";

    t.loginUser = function(userData) {
        var token = userData.token;
        var email = userData.email;
        localStorage.setItem(tokenKey, token);
        localStorage.setItem(emailKey, email);
    };

    t.getToken = function() {
        return localStorage.getItem(tokenKey);
    };

    t.logoutUser = function() {
        localStorage.removeItem(tokenKey);
        localStorage.removeItem(emailKey);
    };

})();
@@ -529,13 +529,213 @@
     %7D;%0A%0A
+    t.requireLogin = function(callback) %7B%0A        var token = t.getToken();%0A        if (token) %7B%0A            callback();%0A        %7D else %7B%0A            klp.login_modal.open(callback);%0A        %7D%0A    %7D;%0A%0A
 %7D)();

add a klp.auth.requireLogin method that can be passed functions that require login