3 const { TemplateHelper: th
} = require('@squeep/html-template-helper');
4 const { sessionNavLinks
} = require('./helpers');
7 * Login form, continued.
10 function otpSection(ctx
, options
) {
11 const otpBlurb
= (options
.otpBlurb
|| []).map((x
) => '\t'.repeat(6) + x
).join('\n');
12 return `\t\t\t<section class="otp">
13 \t\t\t\t<form method="POST">
15 \t\t\t\t\t\t<legend>Two-Factor Authentication</legend>
16 \t\t\t\t\t\t<label for="otp">OTP Code</label>
17 \t\t\t\t\t\t<input type="tel" id="otp" name="otp" value="">
19 \t\t\t\t\t\t<button type="submit">Confirm</button>
22 \t\t\t\t\t<input type="hidden" name="state" value="${ctx.otpState}">
31 * @param {String[]=} ctx.errors
32 * @param {String} ctx.otpState
33 * @param {Object} options
34 * @param {String[]=} options.authenticator.otpBlurb
35 * @param {String[]=} options.authenticator.loginBlurb
36 * @param {Object} options.manager
37 * @param {String} options.manager.pageTitle
38 * @param {String=} options.manager.logoUrl
39 * @param {Object} options.dingus
40 * @param {String} options.dingus.selfBaseUrl
41 * @param {() => {}} appCb
44 module
.exports
= (ctx
, options
, appCb
= () => {}) => {
45 const pagePathLevel
= 1;
47 pageIdentifier: 'otp',
48 pageTitle: options
.manager
.pageTitle
,
49 logoUrl: options
.manager
.logoUrl
,
50 footerEntries: options
.manager
.footerEntries
,
51 otpBlurb: options
.authenticator
?.otpBlurb
,
53 appCb(pagePathLevel
, ctx
, htmlOptions
);
54 sessionNavLinks(pagePathLevel
, ctx
, htmlOptions
);
56 ...(options
.authenticator
?.loginBlurb
|| []),
57 otpSection(ctx
, htmlOptions
),
59 return th
.htmlPage(pagePathLevel
, ctx
, htmlOptions
, mainContent
);