Permalink
Browse files

Fixes

  • Loading branch information...
1 parent 43efe26 commit 9d1cdf45912a203beb1b2397069bf47b31940fd5 Yogesh committed Sep 10, 2012
@@ -28,6 +28,8 @@ function processResponse(that, req, res, action) {
PageRenderer.checkPagePermissions(req, res, function (err) {
if (err)
return PageRenderer.showErrorPage(err, req.attrs.page, req, res);
+
+ req = that.getPluginHelper().cloneRequest(req, that._id)
if (that.isAsync()) {
if ((req.query.mode == "exclusive")) {
action.call(that, req, res, callResponseMethod);
View
@@ -17,7 +17,7 @@ var plugins = require('./plugins'), Step = require('step'), DBActions = require(
LOGIN_PLUGIN_ID = "login";
var EventEmitter = require('events').EventEmitter;
-var layoutOneColumn = "1-col", path = require("path"),fs = require("fs");
+var layoutOneColumn = "1-col", path = require("path"), fs = require("fs");
exports.renderExclusive = function (req, res) {
renderPlugin(req, res, function (err, html) {
@@ -407,7 +407,7 @@ function renderLayout(obj) {
var pluginNS = pluginInstance.pluginNamespace;
var AJAX_TMPL = "<div id='" + pluginNS + "' />", pluginContent, customClass = "", plugin,
obj = PluginHelper.getPluginIdAndIId(pluginNS);
- var cloneReq = PluginHelper.cloneRequest(req), pluginId = obj.pluginId;
+ var pluginId = obj.pluginId, cloneReq = PluginHelper.cloneRequest(req, pluginId);
cloneReq.params.plugin = pluginId;
cloneReq.params.iId = obj.iId;
cloneReq.params.namespace = pluginNS;
View
@@ -71,7 +71,7 @@ var populateModel = exports.populateModel = function (app, modelName, params, ot
if (_.isUndefined(val) || val === "" || val === null) {
var tempKey = keyMapObj[key],
tempVal = tempKey && params[tempKey];
- if(!_.isUndefined(tempVal) && tempVal !== null){
+ if (!_.isUndefined(tempVal) && tempVal !== null) {
val = tempVal;
}
}
@@ -97,24 +97,31 @@ exports.getNamespace = function (req) {
* Basic clone of request
* @param req
*/
-exports.cloneRequest = function (req) {
- var params = req.params;
+exports.cloneRequest = function (req, pluginId) {
+ var params = req.params, requestedPluginId = params.plugin;
var clone = {
- params:{},
- query:req.query,
- body:req.body,
+ params:{
+ page:params.page
+ },
+ query:{},
+ body:{},
app:req.app,
url:req.url,
method:req.method,
cookies:req.cookies,
session:req.session,
xhr:req.xhr,
attrs:_.clone(req.attrs),
- flash:req.flash
+ flash:req.flash,
+ files:_.clone(req.files)
};
- Object.keys(params).forEach(function (param) {
- clone.params[param] = params[param];
- });
+ if (pluginId === requestedPluginId) {
+ clone.query = req.query, clone.body = req.body;
+ Object.keys(params).forEach(function (param) {
+ clone.params[param] = params[param];
+ });
+ }
+
return clone;
};
View
@@ -10,7 +10,7 @@ function getRoute(params) {
return (params.isAppRoute ? AppURL + "/" : "/:page/") + params.pluginId + (params.many ? "/:iId" : "") + params.route;
}
-exports.createRoute = function (app, method, params, fn, action) {
+exports.createRoute = function (app, method, params, fn) {
var route = new Route(method.toLowerCase(), getRoute(params), fn);
if (!params.isAppRoute) {
routes.push(route)
View
@@ -39,12 +39,14 @@ exports.processLogin = function (req, res, login, next) {
}
if (result && result === true) {
- req.session.regenerate(function () {
- req.session.loggedIn = true;
- req.session.user = _.clone(user);
- req.session.roles = user.roles;
- req.session.cookie.expires = new Date(Date.now() + SESSION_MAX_AGE);
- req.session.cookie.maxAge = SESSION_MAX_AGE;
+ var session = req.session;
+ session.regenerate(function () {
+ session = session.req.session; //workaround for cloned request to get correct session
+ session.loggedIn = true;
+ session.user = _.clone(user);
+ session.roles = user.roles;
+ session.cookie.expires = new Date(Date.now() + SESSION_MAX_AGE);
+ session.cookie.maxAge = SESSION_MAX_AGE;
ResponseHelper.setRedirect(req, redirect);
//The Page response next function should be called here as this is in other function
View
@@ -2,7 +2,7 @@
"author":"Yogesh <saggiyogesh@gmail.com>",
"name":"nodeportal",
"description":"Portal based cms written in node.js",
- "version":"0.0.3",
+ "version":"0.0.4",
"homepage":"nodeportal.com",
"keywords":["cms", "node", "nodejs", "portal", "mongodb", "express", "mongoose", "twitter-bootstrap", "ckeditor", "easy", "fast"],
"repository":{
@@ -40,7 +40,7 @@ $(function () {
//bind to version tab click
$('.manage-articles a[data-toggle="tab"]').on('shown', function (e) {
if ($(e.currentTarget).data("id") == "version" && $("#versionTableContentBox").children().length == 0) {
- console.log(e);
+ //console.log(e);
var options = {
url:Rocket.PluginURL({action:"getArticleVersions"}) + "/" + id,
success:function (response) {
@@ -119,26 +119,26 @@ $(function () {
});
Rocket.bind("manageArticle:listTableMenu:" + EDIT_ARTICLE_COMMAND, function (e) {
- console.log(e);
+ //console.log(e);
var id = $('td:eq(1)', e.data.el).text();
goTo(getURL("edit") + "/" + id);
});
Rocket.bind("manageArticle:listTableMenu:" + DELETE_ARTICLE_COMMAND, function (e) {
- console.log(e);
+ //console.log(e);
var id = $('td:eq(1)', e.data.el).text();
removeArticles(id);
});
Rocket.bind("manageArticle:listTableMenu:" + PREVIEW_ARTICLE_COMMAND, function (e) {
- console.log(e);
+ //console.log(e);
var id = $('td:eq(1)', e.data.el).text();
window.open(getURL("preview") + "/" + id, '_blank');
});
Rocket.bind("manageArticle:listTableMenu:" + PERMISSION_COMMAND, function (e) {
- console.log(e);
+ //console.log(e);
var articleId = $('td:eq(0)', e.data.el).find("input").val(),
origin = Rocket.Util.getOrigin(),
redirect = encodeURIComponent(getURL("")),
@@ -125,7 +125,7 @@ function editPlugin(req, res, next) {
pluginSettings:instance.settings || {}
};
- var url = URLCreator.createExclusiveURLFromRequest(that.getPluginHelper().cloneRequest(req)).setAction("updatePluginSettings");
+ var url = URLCreator.createExclusiveURLFromRequest(that.getPluginHelper().cloneRequest(req, that.getPluginId())).setAction("updatePluginSettings");
settingsFn(obj, function (err, config) {
var viewPath = req.app.set('appPath') + "/plugins/" + pluginId + "/views/"
+ config.jade , view = PageRenderer.viewParser(req, viewPath, {
@@ -19,14 +19,14 @@ $(function () {
var form = e.currentTarget;
appendFormFields(form);
Rocket.Util.submitFormAsync(form, function (responseData) {
- console.log(responseData)
+ //console.log(responseData)
$("#" + ns + " .plugin-head .header").html(responseData.title.en_US);
});
});
settingsArea.find("form").submit(function (e) {
e.preventDefault();
- console.log(e);
+ //console.log(e);
var form = e.currentTarget;
appendFormFields(form);
Rocket.Util.submitFormAsync(form, function (responseData) {
@@ -41,11 +41,11 @@ $(function () {
function handlePermissionUpdate(){
permissionArea.find("form").submit(function (e) {
e.preventDefault();
- console.log(e);
+ //console.log(e);
var form = e.currentTarget;
appendFormFields(form);
Rocket.Util.submitFormAsync(form, function (responseData) {
- console.log(responseData);
+ //console.log(responseData);
if(responseData && responseData.status && responseData.status == "success"){
location.reload();
}
@@ -55,14 +55,13 @@ $(function () {
managePlugin.find('a[data-toggle="tab"]').on('shown', function (e) {
if ($(e.currentTarget).data("id") == "permissions") {
- console.log(Rocket.Util.getOrigin() + Rocket.PageValues.getPageFriendlyURL() + "/managePermissions/plugin/"
- + instanceId + "/" + ns)
+ //console.log(Rocket.Util.getOrigin() + Rocket.PageValues.getPageFriendlyURL() + "/managePermissions/plugin/"+ instanceId + "/" + ns)
var options = {
url:Rocket.Util.getOrigin() + Rocket.PageValues.getPageFriendlyURL() + "/managePermissions/plugin/"
+ instanceId + "/" + ns,
data:{mode:"exclusive"},
success:function (response) {
- console.log(response);
+ //console.log(response);
permissionArea.html(response);
handlePermissionUpdate();
}
@@ -72,5 +71,5 @@ $(function () {
});
- console.log(managePlugin)
+ //console.log(managePlugin)
});
@@ -242,7 +242,7 @@ $(function () {
function handleItemClick(e) {
- console.log(e);
+ //console.log(e);
resetAllMsgs();
var tgt = e.currentTarget, id = tgt.children[0].id;
//open item in resouce view in edit mode
@@ -254,8 +254,7 @@ $(function () {
updateBreadcrumb();
//continue on this code
- //TODO has to think of functionality of UI
- console.log(model);
+ //console.log(model);
//resourceView.html();
if (model.type == FOLDER_TYPE) {
renderItemsByFolderId(model.resourceId);
@@ -355,7 +354,7 @@ $(function () {
//bind manageResource:resourceView:change event
Rocket.bind("manageResource:resourceViewList:change", function (e) {
- console.log("manageResource:resourceView");
+ //console.log("manageResource:resourceView");
resourceModels = e.data;
resourceTreeList.html("");
@@ -86,7 +86,7 @@ $(function () {
}
};
Rocket.ajax(options);
- console.log(id);
+ //console.log(id);
});
View
@@ -56,7 +56,7 @@ $(function () {
obj[i].push($(n).attr("id"))
});
});
- console.log(obj);
+ //console.log(obj);
var options = {
url:"/app/updatePageData",
method:"POST",
View
@@ -18,7 +18,7 @@
var namespace = options.namespace;
list[namespace] = options.props;
Rocket.trigger("plugin:" + namespace + ":ready");
- console.log(list);
+ //console.log(list);
},
getThisPluginId:function () {
//get this from URL
View
@@ -22,7 +22,7 @@
if (options.contextMenu) {
var that = this;
opts["fnRowCallback"] = function (nRow, aData, iDisplayIndex, iDisplayIndexFull) {
- console.log(nRow);
+ //console.log(nRow);
var obj = {
hasCheckbox:options.checkBoxAll ? true : false,
contextMenu:options.contextMenu,

0 comments on commit 9d1cdf4

Please sign in to comment.