From 3501e7042eeb4a104e4f001b2641d41023087b1a Mon Sep 17 00:00:00 2001 From: Justin Wind Date: Wed, 20 Mar 2024 17:19:23 -0700 Subject: [PATCH] remove hard-coded navLinks entirely, let other modules populate them --- README.md | 12 ------------ lib/template-helper.js | 21 +-------------------- 2 files changed, 1 insertion(+), 32 deletions(-) diff --git a/README.md b/README.md index 32f2673..888bd54 100644 --- a/README.md +++ b/README.md @@ -19,18 +19,6 @@ Specific to Squeep Framework Applications, this module has strong opinions and m ### Context -The context is referenced for authenticated user information, as well as messaging. - -- `ctx.session.authenticatedIdentifier` -- `ctx.session.authenticatedProfile` - -If either of these are present, navigation links are added to the page header allowing the user to manage their account or log out. -The links will point relatively to `/admin/settings` and `/admin/logout`, respectively. - -- `ctx.url` - -If present, added as a query parameter (`r`, for redirect) to the logout link. - - `ctx.errors` - `ctx.notifications` diff --git a/lib/template-helper.js b/lib/template-helper.js index e48cdb4..7f7021a 100644 --- a/lib/template-helper.js +++ b/lib/template-helper.js @@ -358,12 +358,9 @@ ${UL(ctx.notifications, 1)} /** - * Render all parts of an HTML page. Adds user logout nav link automatically. + * Render all parts of an HTML page. * @param {Number} pagePathLevel - relative path-distance to base * @param {Object} ctx - * @param {Object=} ctx.session - * @param {String=} ctx.session.authenticatedIdentifier - * @param {String=} ctx.session.authenticatedProfile * @param {String[]=} ctx.errors * @param {String[]=} ctx.notifications * @param {Object} options @@ -382,22 +379,6 @@ ${UL(ctx.notifications, 1)} * @returns {String} */ function htmlPage(pagePathLevel, ctx, options, main = []) { - const user = ctx?.session?.authenticatedProfile || ctx?.session?.authenticatedIdentifier; - if (user) { - if (!options.navLinks) { - options.navLinks = []; - } - const logoutRedirect = ctx?.url ? `?r=${encodeURIComponent(ctx.url)}` : ''; - const adminPath = (pagePathLevel > 0) ? `${'../'.repeat(pagePathLevel - 1)}` : 'admin/'; - options.navLinks.push({ - text: 'Account', - href: `${adminPath}settings`, - }, { - text: `Logout (${user})`, - href: `${adminPath}logout${logoutRedirect}`, - }); - } - return [ '', '', -- 2.44.1