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