3 const th
= require('./template-helper');
9 function indieAuthSection() {
10 return ` <section class="indieauth">
12 <form action="" method="POST">
14 <legend>IndieAuth</legend>
15 <label for="me">Profile URL:</label>
16 <input id="me" name="me" type="url" size="40" placeholder="https://example.com/my_profile_url" value="" autofocus>
17 <button>Login</button>
20 Logging in with an <a class="external" href="https://indieweb.org/IndieAuth">IndieAuth</a> profile will allow you to view details of any topics on this hub which are related to that profile's domain.
28 function userSection(ctx
, options
) {
29 const secure
= (ctx
.clientProtocol
|| '').toLowerCase() === 'https';
30 const showUserForm
= secure
|| !options
.authenticator
.secureAuthOnly
;
31 return showUserForm
? ` <section class="user">
32 <form action="" method="POST">
34 <legend>User Account</legend>
35 <label for="identifier">Username:</label>
36 <input id="identifier" name="identifier" value="">
38 <label for="credential">Password:</label>
39 <input id="credential" name="credential" type="password" value="">
41 <button>Login</button>
50 function errorsSection(ctx
) {
51 return (ctx
.errors
&& ctx
.errors
.length
) ? ` <section class="errors">
53 <p>Problems were encountered while trying to authenticate you.</p>
55 ctx
.errors
.map((error
) => `<li>${error}</li>`).join('\n') + `
63 * Render login form for both local and profile authentication.
65 * @param {Object} options
66 * @param {Object} options.manager
67 * @param {String} options.manager.pageTitle
68 * @param {Object} options.dingus
69 * @param {String} options.dingus.selfBaseUrl
72 module
.exports
= (ctx
, options
) => {
73 const pageTitle
= options
.manager
.pageTitle
;
74 const footerEntries
= options
.manager
.footerEntries
;
75 const headElements
= [];
80 userSection(ctx
, options
),
82 return th
.htmlTemplate(ctx
, 2, pageTitle
, headElements
, navLinks
, mainContent
, footerEntries
);