const { sessionNavLinks } = require('@squeep/authentication-module');
+/**
+ *
+ * @param {string} profile profile
+ * @returns {string} option
+ */
function renderProfileOption(profile) {
return `<option value="${profile}">${profile}</option>`;
}
+/**
+ *
+ * @param {string} scope scope
+ * @returns {string} tr
+ */
function renderScopeCheckboxTR(scope) {
const defaultChecked = ['read'];
const checked = defaultChecked.includes(scope) ? ' checked' : '';
return `<tr class="scope">
-\t<td><input type="checkbox" id="scopes-${scope}" name="scopes" value="${scope}"${checked}></td>
+\t<td><input type="checkbox" id="scopes-${scope}" name="scopes[]" value="${scope}"${checked}></td>
\t<td>${scope}</td>
</tr>`;
}
+/**
+ *
+ * @param {object} ctx context
+ * @returns {string} section
+ */
function mainContent(ctx) {
const profileOptions = th.indented(4, (ctx?.profilesScopes?.profiles || []).map((profile) => renderProfileOption(profile)))
.join('\n');
const elideScopes = ['profile', 'email'];
const allScopes = Object.keys(ctx?.profilesScopes?.scopeIndex || {});
const displayScopes = (allScopes).filter((scope) => !elideScopes.includes(scope));
- const scopesCheckboxRows = th.indented(4, displayScopes.map((scope) => renderScopeCheckboxTR(scope)))
+ const scopesCheckboxRows = th.indented(5, displayScopes.map((scope) => renderScopeCheckboxTR(scope)))
.join('\n');
return `<section>
-\t<form action="" method="POST">
+\t<form method="POST">
\t\t<div>
\t\t\tYou may proactively send a ticket to a third-party site,
\t\t\twhich they may redeem for an access token which grants additional
<fieldset>
<legend>Scopes</legend>
\t\t\t<table>
+\t\t\t\t<tbody>
${scopesCheckboxRows}
+\t\t\t\t</tbody>
\t\t\t</table>
</fieldset>
\t\t\t<br>
\t\t\t<label for="scopes-adhoc">Additional Scopes (space separated):</label>
\t\t\t<input type="text" id="scopes-adhoc" name="adhoc" size="96">
\t\t\t<br>
-\t\t\t<button name="action" value="proffer-ticket">Send Ticket</button>
+\t\t\t<button type="submit" name="action" value="proffer-ticket">Send Ticket</button>
\t\t</fieldset>
\t</form>
</section>`;
/**
*
- * @param {Object} ctx
- * @param {Object} ctx.profilesScopes.scopeIndex
- * @param {String[]} ctx.profileScopes.profiles
- * @param {Object} options
- * @param {Object} options.manager
- * @param {String} options.manager.pageTitle
- * @param {String} options.manager.logoUrl
- * @param {String[]} options.manager.footerEntries
- * @returns {String}
+ * @param {object} ctx context
+ * @param {object} ctx.profilesScopes.scopeIndex scopes structure
+ * @param {string[]} ctx.profileScopes.profiles profile
+ * @param {object} options options
+ * @param {object} options.manager manager options
+ * @param {string} options.manager.pageTitle page title
+ * @param {string} options.manager.logoUrl logo url
+ * @param {string[]} options.manager.footerEntries footer entries
+ * @returns {string} page
*/
module.exports = (ctx, options) => {
const pagePathLevel = 1;
const htmlOptions = {
- padeIdentifier: 'ticketProffer',
+ pageIdentifier: 'ticketProffer',
pageTitle: options.manager.pageTitle + ' - Ticket Proffer',
logoUrl: options.manager.logoUrl,
footerEntries: options.manager.footerEntries,