X-Git-Url: http://git.squeep.com/?a=blobdiff_plain;f=lib%2Ftemplate%2Flogin-html.js;h=8ee7392ad9f4883150546a444f1f4c7c23a2c42f;hb=2c3ddf0a6f40b9d0a4e54fa12b84b8af33eaaadc;hp=7d059e0d505caf4d4fb503f554dcd91d9d05ccc3;hpb=dd173e6b450cbba8100883514610c9fde83d050a;p=squeep-authentication-module diff --git a/lib/template/login-html.js b/lib/template/login-html.js index 7d059e0..8ee7392 100644 --- a/lib/template/login-html.js +++ b/lib/template/login-html.js @@ -1,6 +1,7 @@ 'use strict'; const { TemplateHelper: th } = require('@squeep/html-template-helper'); +const { sessionNavLinks } = require('./helpers'); /** * Login form. @@ -10,12 +11,13 @@ function indieAuthSection(ctx, options) { const showIndieAuthForm = options.authnEnabled.includes('indieAuth'); return showIndieAuthForm ? `\t\t\t
\t\t\t\t

Login

-\t\t\t\t
+\t\t\t\t \t\t\t\t\t
\t\t\t\t\t\tIndieAuth \t\t\t\t\t\t \t\t\t\t\t\t -\t\t\t\t\t\t +\t\t\t\t\t\t +\t\t\t\t\t\t ${indieAuthBlurb} \t\t\t\t\t
\t\t\t\t
@@ -24,23 +26,61 @@ ${indieAuthBlurb} } -const userAuthn = ['argon2', 'pam', 'DEBUG_ANY']; +/** + * Default all URL inputs to https if scheme not specified, + * and set a flag if that happened. + * From https://aaronparecki.com/2019/05/13/2/https + */ +function indieAuthURLTrySecureFirstScript(ctx, options) { + const showIndieAuthForm = options.authnEnabled.includes('indieAuth'); + return showIndieAuthForm ? ` +` : ''; +} + +const userAuthn = ['argon2', 'pam']; function userSection(ctx, options) { const userBlurb = (options.userBlurb || []).map((x) => '\t'.repeat(6) + x).join('\n'); const secure = (ctx.clientProtocol || '').toLowerCase() === 'https'; const showUserForm = options.authnEnabled.filter((x) => userAuthn.includes(x)).length && (secure || !options.secureAuthOnly); return showUserForm ? `\t\t\t
-\t\t\t\t
+\t\t\t\t \t\t\t\t\t
\t\t\t\t\t\tUser Account \t\t\t\t\t\t -\t\t\t\t\t\t +\t\t\t\t\t\t \t\t\t\t\t\t
\t\t\t\t\t\t \t\t\t\t\t\t \t\t\t\t\t\t
-\t\t\t\t\t\t +\t\t\t\t\t\t ${userBlurb} \t\t\t\t\t
\t\t\t\t
@@ -64,10 +104,13 @@ ${userBlurb} * @param {String=} options.manager.logoUrl * @param {Object} options.dingus * @param {String} options.dingus.selfBaseUrl + * @param {() => {}} appCb * @returns {String} */ -module.exports = (ctx, options) => { +module.exports = (ctx, options, appCb = () => {}) => { + const pagePathLevel = 1; const htmlOptions = { + pageIdentifier: 'login', pageTitle: options.manager.pageTitle, logoUrl: options.manager.logoUrl, footerEntries: options.manager.footerEntries, @@ -76,10 +119,13 @@ module.exports = (ctx, options) => { indieAuthBlurb: options.authenticator.indieAuthBlurb, userBlurb: options.authenticator.userBlurb, }; + appCb(pagePathLevel, ctx, htmlOptions); + sessionNavLinks(pagePathLevel, ctx, htmlOptions); const mainContent = [ ...(options.authenticator.loginBlurb || []), + indieAuthURLTrySecureFirstScript(ctx, htmlOptions), indieAuthSection(ctx, htmlOptions), userSection(ctx, htmlOptions), ]; - return th.htmlPage(2, ctx, htmlOptions, mainContent); + return th.htmlPage(pagePathLevel, ctx, htmlOptions, mainContent); }; \ No newline at end of file