initial commit
[squeep-authentication-module] / lib / template / ia-html.js
diff --git a/lib/template/ia-html.js b/lib/template/ia-html.js
new file mode 100644 (file)
index 0000000..00e2089
--- /dev/null
@@ -0,0 +1,40 @@
+'use strict';
+
+const { TemplateHelper: th } = require('@squeep/html-template-helper');
+
+function mainContent() {
+  return [
+    `<section>
+\t<a href="./login">Try Again?</a>
+</section>`,
+  ];
+}
+
+/**
+ * Render any errors from attempting IndieAuth.
+ * @param {Object} ctx
+ * @param {String[]} ctx.errors
+ * @param {Object} options
+ * @param {Object} options.manager
+ * @param {String} options.manager.pageTitle
+ * @param {Object} options.dingus
+ * @param {String} options.dingus.selfBaseUrl
+ * @returns {String}
+ */
+module.exports = (ctx, options) => {
+  const htmlOptions = {
+    pageTitle: options.manager.pageTitle,
+    logoUrl: options.manager.logoUrl,
+    footerEntries: options.manager.footerEntries,
+    errorContent: [
+      '<p>Problems were encountered while trying to authenticate your profile URL.</p>',
+    ],
+  };
+  // Ensure there is always an error to report, even if we do not have one, as we ended up here somehow.
+  if (!ctx.errors || !ctx.errors.length) {
+    ctx.errors = [
+      'Unknown Error &mdash; we are not sure what just happened',
+    ];
+  }
+  return th.htmlPage(2, ctx, htmlOptions, mainContent());
+};
\ No newline at end of file