From 37286ec01219d8cfc024d7b3e9f5218e7aafbfa9 Mon Sep 17 00:00:00 2001 From: Nikolai Onken Date: Tue, 7 Jul 2015 08:50:06 +0000 Subject: [PATCH] Fix login / error handling --- node_modules/frontdoor/lib/section.js | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/node_modules/frontdoor/lib/section.js b/node_modules/frontdoor/lib/section.js index 3ad67591..0b21c861 100644 --- a/node_modules/frontdoor/lib/section.js +++ b/node_modules/frontdoor/lib/section.js @@ -96,24 +96,30 @@ module.exports = function Section(name, description, types) { */ this.mount = function(name, section) { - if ( arguments.length == 1 ){ + var that = this; + + if (arguments.length == 1) { section = arguments[0]; - - if ( ! ( section instanceof Section ) ) + + if (!(section instanceof Section)) throw new Error("Single argument to mount must be a Section!"); - + var addRoutes = section.getRoutes(); - - Object.keys(addRoutes).forEach(function( method){ - routes[method] = [].concat( routes[method], addRoutes[method] ); + + Object.keys(addRoutes).forEach(function(method) { + var r = addRoutes[method]; + r.forEach(function(route) { + route.parent = that; + }) + routes[method] = [].concat(routes[method], r); }); - + return; } - + if (!sections[name]) sections[name] = []; - + section.parent = this; sections[name].push(section); };