rudimentary support for totp 2fa
[squeep-authentication-module] / lib / template / ia-html.js
1 'use strict';
2
3 const { TemplateHelper: th } = require('@squeep/html-template-helper');
4
5 /**
6 *
7 * @returns {String}
8 */
9 function mainContent() {
10 return [
11 `<section>
12 \t<a href="./login">Try Again?</a>
13 </section>`,
14 ];
15 }
16
17 /**
18 * Render any errors from attempting IndieAuth.
19 * @param {Object} ctx
20 * @param {String[]} ctx.errors
21 * @param {Object} options
22 * @param {Object} options.manager
23 * @param {String} options.manager.pageTitle
24 * @param {Object} options.dingus
25 * @param {String} options.dingus.selfBaseUrl
26 * @returns {String}
27 */
28 module.exports = (ctx, options) => {
29 const htmlOptions = {
30 pageTitle: options.manager.pageTitle,
31 logoUrl: options.manager.logoUrl,
32 footerEntries: options.manager.footerEntries,
33 errorContent: [
34 '<p>Problems were encountered while trying to authenticate your profile URL.</p>',
35 ],
36 };
37 // Ensure there is always an error to report, even if we do not have one, as we ended up here somehow.
38 if (!ctx?.errors?.length) {
39 ctx.errors = [
40 'Unknown Error &mdash; we are not sure what just happened',
41 ];
42 }
43 return th.htmlPage(2, ctx, htmlOptions, mainContent());
44 };