7d059e0d505caf4d4fb503f554dcd91d9d05ccc3
3 const { TemplateHelper: th
} = require('@squeep/html-template-helper');
8 function indieAuthSection(ctx
, options
) {
9 const indieAuthBlurb
= (options
.indieAuthBlurb
|| []).map((x
) => '\t'.repeat(6) + x
).join('\n');
10 const showIndieAuthForm
= options
.authnEnabled
.includes('indieAuth');
11 return showIndieAuthForm
? `\t\t\t<section class="indieauth">
12 \t\t\t\t<h2>Login</h2>
13 \t\t\t\t<form action="" method="POST">
15 \t\t\t\t\t\t<legend>IndieAuth</legend>
16 \t\t\t\t\t\t<label for="me">Profile URL:</label>
17 \t\t\t\t\t\t<input id="me" name="me" type="url" size="40" placeholder="https://example.com/my_profile_url" value="" autofocus>
18 \t\t\t\t\t\t<button>Login</button>
27 const userAuthn
= ['argon2', 'pam', 'DEBUG_ANY'];
28 function userSection(ctx
, options
) {
29 const userBlurb
= (options
.userBlurb
|| []).map((x
) => '\t'.repeat(6) + x
).join('\n');
30 const secure
= (ctx
.clientProtocol
|| '').toLowerCase() === 'https';
31 const showUserForm
= options
.authnEnabled
.filter((x
) => userAuthn
.includes(x
)).length
32 && (secure
|| !options
.secureAuthOnly
);
33 return showUserForm
? `\t\t\t<section class="user">
34 \t\t\t\t<form action="" method="POST">
36 \t\t\t\t\t\t<legend>User Account</legend>
37 \t\t\t\t\t\t<label for="identifier">Username:</label>
38 \t\t\t\t\t\t<input id="identifier" name="identifier" value="">
40 \t\t\t\t\t\t<label for="credential">Password:</label>
41 \t\t\t\t\t\t<input id="credential" name="credential" type="password" value="">
43 \t\t\t\t\t\t<button>Login</button>
53 * Render login form for both local and profile authentication.
55 * @param {String[]=} ctx.errors
56 * @param {String} ctx.clientProtocol
57 * @param {Object} options
58 * @param {Boolean} options.authenticator.secureAuthOnly
59 * @param {String[]=} options.authenticator.loginBlurb
60 * @param {String[]=} options.authenticator.indieAuthBlurb
61 * @param {String[]=} options.authenticator.userBlurb
62 * @param {Object} options.manager
63 * @param {String} options.manager.pageTitle
64 * @param {String=} options.manager.logoUrl
65 * @param {Object} options.dingus
66 * @param {String} options.dingus.selfBaseUrl
69 module
.exports
= (ctx
, options
) => {
71 pageTitle: options
.manager
.pageTitle
,
72 logoUrl: options
.manager
.logoUrl
,
73 footerEntries: options
.manager
.footerEntries
,
74 secureAuthOnly: options
.authenticator
.secureAuthOnly
,
75 authnEnabled: options
.authenticator
.authnEnabled
,
76 indieAuthBlurb: options
.authenticator
.indieAuthBlurb
,
77 userBlurb: options
.authenticator
.userBlurb
,
80 ...(options
.authenticator
.loginBlurb
|| []),
81 indieAuthSection(ctx
, htmlOptions
),
82 userSection(ctx
, htmlOptions
),
84 return th
.htmlPage(2, ctx
, htmlOptions
, mainContent
);