From: Justin Wind Date: Thu, 21 Mar 2024 00:19:23 +0000 (-0700) Subject: remove hard-coded navLinks entirely, let other modules populate them X-Git-Tag: v1.6.0~3 X-Git-Url: http://git.squeep.com/?a=commitdiff_plain;h=3501e7042eeb4a104e4f001b2641d41023087b1a;hp=084ad86d1dde896c0f49498f5573fcc6a60fddd8;p=squeep-html-template-helper remove hard-coded navLinks entirely, let other modules populate them --- 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 [ '', '',