Update portal for Omada vouchers
Browse files- portal-payment-preview.html +16 -16
- public/engine.js +3 -6
- src/jobs/index.js +8 -0
- src/jobs/syncPortalTemplates.job.js +48 -0
- src/routes/plans.routes.js +54 -20
- src/routes/portal.routes.js +2 -2
- src/views/screens/portal.ejs +10 -10
portal-payment-preview.html
CHANGED
|
@@ -640,7 +640,7 @@
|
|
| 640 |
<div class="payment-head">
|
| 641 |
<div>
|
| 642 |
<h3>Pay the business directly</h3>
|
| 643 |
-
<p>Use the merchant ID below, then show payment confirmation and receive your
|
| 644 |
</div>
|
| 645 |
<div class="badge" id="active-provider-badge">Selcom</div>
|
| 646 |
</div>
|
|
@@ -762,11 +762,11 @@ Use merchant ID 4412088 and complete the payment.</div>
|
|
| 762 |
<p class="helper-note">The layout above gives the merchant ID more visual emphasis and keeps the instructions readable on narrow screens.</p>
|
| 763 |
|
| 764 |
<div class="online-payment">
|
| 765 |
-
<label class="field-label" for="phone-input">
|
| 766 |
-
<input class="phone-input" id="phone-input" type="text" placeholder="Enter
|
| 767 |
-
<p class="input-hint">Enter the voucher
|
| 768 |
<div class="error-msg" id="select-error"></div>
|
| 769 |
-
<button class="primary-btn" id="pay-btn" type="button" disabled>Enter
|
| 770 |
</div>
|
| 771 |
|
| 772 |
<button class="token-cta" type="button" id="show-code-entry">
|
|
@@ -774,21 +774,21 @@ Use merchant ID 4412088 and complete the payment.</div>
|
|
| 774 |
<div class="token-cta-row">
|
| 775 |
<div>
|
| 776 |
<span class="token-cta-title">Enter an existing code</span>
|
| 777 |
-
<span class="token-cta-copy">Paid the business already?
|
| 778 |
</div>
|
| 779 |
<span class="token-cta-icon">→</span>
|
| 780 |
</div>
|
| 781 |
</button>
|
| 782 |
|
| 783 |
-
<div class="token-note">This hotspot is currently configured for direct business payment only. Choose one plan, pay the business above, and
|
| 784 |
<div class="support-inline">Need help? Call 0748334009</div>
|
| 785 |
</div>
|
| 786 |
|
| 787 |
<div id="screen-waiting" class="screen">
|
| 788 |
<div class="payment-status">
|
| 789 |
<div class="spinner"></div>
|
| 790 |
-
<strong>Authenticating
|
| 791 |
-
<span>Sending the
|
| 792 |
<div class="error-msg" id="payment-error"></div>
|
| 793 |
<button class="ghost-btn" id="cancel-btn" type="button">Cancel</button>
|
| 794 |
</div>
|
|
@@ -796,8 +796,8 @@ Use merchant ID 4412088 and complete the payment.</div>
|
|
| 796 |
|
| 797 |
<div id="screen-code" class="screen">
|
| 798 |
<div class="online-payment">
|
| 799 |
-
<label class="field-label" for="code-input">
|
| 800 |
-
<input class="code-input" id="code-input" type="text" placeholder="Enter
|
| 801 |
<div class="error-msg" id="code-error"></div>
|
| 802 |
<button class="primary-btn" id="code-submit-btn" type="button">Connect</button>
|
| 803 |
<button class="ghost-btn" id="show-plans" type="button">Back to plans</button>
|
|
@@ -807,7 +807,7 @@ Use merchant ID 4412088 and complete the payment.</div>
|
|
| 807 |
<div id="screen-success" class="screen">
|
| 808 |
<div class="success-panel">
|
| 809 |
<strong>Connected</strong>
|
| 810 |
-
<span>The
|
| 811 |
<div class="code-value" id="success-code">----</div>
|
| 812 |
<span id="success-meta"></span>
|
| 813 |
</div>
|
|
@@ -994,10 +994,10 @@ Use merchant ID 4412088 and complete the payment.</div>
|
|
| 994 |
function updatePayButton() {
|
| 995 |
if (!authButton) return;
|
| 996 |
if (currentToken()) {
|
| 997 |
-
authButton.textContent = "Authenticate
|
| 998 |
authButton.disabled = false;
|
| 999 |
} else {
|
| 1000 |
-
authButton.textContent = "Enter
|
| 1001 |
authButton.disabled = true;
|
| 1002 |
}
|
| 1003 |
}
|
|
@@ -1020,7 +1020,7 @@ Use merchant ID 4412088 and complete the payment.</div>
|
|
| 1020 |
function authenticateToken(token, errorElement) {
|
| 1021 |
clearError(errorElement);
|
| 1022 |
if (!token) {
|
| 1023 |
-
showError(errorElement, "Enter the
|
| 1024 |
return;
|
| 1025 |
}
|
| 1026 |
if (!submitUrl) {
|
|
@@ -1047,7 +1047,7 @@ Use merchant ID 4412088 and complete the payment.</div>
|
|
| 1047 |
isCommited = true;
|
| 1048 |
landingUrl = data.result || landingUrl;
|
| 1049 |
if (successCode) successCode.textContent = token;
|
| 1050 |
-
if (successMeta) successMeta.textContent = "
|
| 1051 |
showScreen("success");
|
| 1052 |
window.location.href = landingUrl;
|
| 1053 |
} else {
|
|
|
|
| 640 |
<div class="payment-head">
|
| 641 |
<div>
|
| 642 |
<h3>Pay the business directly</h3>
|
| 643 |
+
<p>Use the merchant ID below, then show payment confirmation and receive your Omada voucher code from the attendant.</p>
|
| 644 |
</div>
|
| 645 |
<div class="badge" id="active-provider-badge">Selcom</div>
|
| 646 |
</div>
|
|
|
|
| 762 |
<p class="helper-note">The layout above gives the merchant ID more visual emphasis and keeps the instructions readable on narrow screens.</p>
|
| 763 |
|
| 764 |
<div class="online-payment">
|
| 765 |
+
<label class="field-label" for="phone-input">Omada Voucher Code</label>
|
| 766 |
+
<input class="phone-input" id="phone-input" type="text" placeholder="Enter voucher code" autocomplete="one-time-code">
|
| 767 |
+
<p class="input-hint">Enter the voucher code exactly as shown in Omada Hotspot Manager.</p>
|
| 768 |
<div class="error-msg" id="select-error"></div>
|
| 769 |
+
<button class="primary-btn" id="pay-btn" type="button" disabled>Enter voucher</button>
|
| 770 |
</div>
|
| 771 |
|
| 772 |
<button class="token-cta" type="button" id="show-code-entry">
|
|
|
|
| 774 |
<div class="token-cta-row">
|
| 775 |
<div>
|
| 776 |
<span class="token-cta-title">Enter an existing code</span>
|
| 777 |
+
<span class="token-cta-copy">Paid the business already? Enter your Omada voucher code here to connect immediately.</span>
|
| 778 |
</div>
|
| 779 |
<span class="token-cta-icon">→</span>
|
| 780 |
</div>
|
| 781 |
</button>
|
| 782 |
|
| 783 |
+
<div class="token-note">This hotspot is currently configured for direct business payment only. Choose one plan, pay the business above, and enter the Omada voucher code you receive.</div>
|
| 784 |
<div class="support-inline">Need help? Call 0748334009</div>
|
| 785 |
</div>
|
| 786 |
|
| 787 |
<div id="screen-waiting" class="screen">
|
| 788 |
<div class="payment-status">
|
| 789 |
<div class="spinner"></div>
|
| 790 |
+
<strong>Authenticating voucher</strong>
|
| 791 |
+
<span>Sending the Omada voucher code to the controller.</span>
|
| 792 |
<div class="error-msg" id="payment-error"></div>
|
| 793 |
<button class="ghost-btn" id="cancel-btn" type="button">Cancel</button>
|
| 794 |
</div>
|
|
|
|
| 796 |
|
| 797 |
<div id="screen-code" class="screen">
|
| 798 |
<div class="online-payment">
|
| 799 |
+
<label class="field-label" for="code-input">Omada Voucher Code</label>
|
| 800 |
+
<input class="code-input" id="code-input" type="text" placeholder="Enter voucher code" autocomplete="one-time-code">
|
| 801 |
<div class="error-msg" id="code-error"></div>
|
| 802 |
<button class="primary-btn" id="code-submit-btn" type="button">Connect</button>
|
| 803 |
<button class="ghost-btn" id="show-plans" type="button">Back to plans</button>
|
|
|
|
| 807 |
<div id="screen-success" class="screen">
|
| 808 |
<div class="success-panel">
|
| 809 |
<strong>Connected</strong>
|
| 810 |
+
<span>The Omada voucher code was accepted.</span>
|
| 811 |
<div class="code-value" id="success-code">----</div>
|
| 812 |
<span id="success-meta"></span>
|
| 813 |
</div>
|
|
|
|
| 994 |
function updatePayButton() {
|
| 995 |
if (!authButton) return;
|
| 996 |
if (currentToken()) {
|
| 997 |
+
authButton.textContent = "Authenticate Voucher";
|
| 998 |
authButton.disabled = false;
|
| 999 |
} else {
|
| 1000 |
+
authButton.textContent = "Enter voucher";
|
| 1001 |
authButton.disabled = true;
|
| 1002 |
}
|
| 1003 |
}
|
|
|
|
| 1020 |
function authenticateToken(token, errorElement) {
|
| 1021 |
clearError(errorElement);
|
| 1022 |
if (!token) {
|
| 1023 |
+
showError(errorElement, "Enter the Omada voucher code.");
|
| 1024 |
return;
|
| 1025 |
}
|
| 1026 |
if (!submitUrl) {
|
|
|
|
| 1047 |
isCommited = true;
|
| 1048 |
landingUrl = data.result || landingUrl;
|
| 1049 |
if (successCode) successCode.textContent = token;
|
| 1050 |
+
if (successMeta) successMeta.textContent = "Omada voucher accepted. Redirecting...";
|
| 1051 |
showScreen("success");
|
| 1052 |
window.location.href = landingUrl;
|
| 1053 |
} else {
|
public/engine.js
CHANGED
|
@@ -257,10 +257,7 @@
|
|
| 257 |
|
| 258 |
if (codeInput) {
|
| 259 |
codeInput.addEventListener('input', () => {
|
| 260 |
-
//
|
| 261 |
-
let v = codeInput.value.toUpperCase().replace(/[^A-Z0-9]/g, '');
|
| 262 |
-
if (v.length > 4) v = v.slice(0, 4) + '-' + v.slice(4, 8);
|
| 263 |
-
codeInput.value = v;
|
| 264 |
});
|
| 265 |
}
|
| 266 |
|
|
@@ -268,8 +265,8 @@
|
|
| 268 |
codeSubmitBtn.addEventListener('click', async () => {
|
| 269 |
clearError('code-error');
|
| 270 |
const code = codeInput?.value?.trim();
|
| 271 |
-
if (!code || code.length <
|
| 272 |
-
return showError('code-error', 'Enter
|
| 273 |
}
|
| 274 |
if (!P.clientMac) {
|
| 275 |
return showError('code-error', 'Open this portal from the WiFi login page on the device you want to connect.');
|
|
|
|
| 257 |
|
| 258 |
if (codeInput) {
|
| 259 |
codeInput.addEventListener('input', () => {
|
| 260 |
+
codeInput.value = codeInput.value.replace(/[^a-zA-Z0-9]/g, '').slice(0, 32);
|
|
|
|
|
|
|
|
|
|
| 261 |
});
|
| 262 |
}
|
| 263 |
|
|
|
|
| 265 |
codeSubmitBtn.addEventListener('click', async () => {
|
| 266 |
clearError('code-error');
|
| 267 |
const code = codeInput?.value?.trim();
|
| 268 |
+
if (!code || code.length < 6) {
|
| 269 |
+
return showError('code-error', 'Enter the voucher code exactly as shown.');
|
| 270 |
}
|
| 271 |
if (!P.clientMac) {
|
| 272 |
return showError('code-error', 'Open this portal from the WiFi login page on the device you want to connect.');
|
src/jobs/index.js
CHANGED
|
@@ -7,6 +7,7 @@ const pollAlerts = require('./pollAlerts.job');
|
|
| 7 |
const suspendDevices = require('./suspendDevices.job');
|
| 8 |
const billingReminders = require('./billingReminders.job');
|
| 9 |
const syncVoucherGroups = require('./syncVoucherGroups.job');
|
|
|
|
| 10 |
|
| 11 |
function runVoucherGroupSync() {
|
| 12 |
syncVoucherGroups().catch(err => {
|
|
@@ -14,6 +15,12 @@ function runVoucherGroupSync() {
|
|
| 14 |
});
|
| 15 |
}
|
| 16 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 17 |
// adoptDevices — triggered on-demand from POST /api/devices/:id/adopt (not a cron job)
|
| 18 |
// pollSessions — browser triggers every 1 min while dashboard is open (throttled server-side);
|
| 19 |
// cron below is the fallback when no dashboard is open
|
|
@@ -29,6 +36,7 @@ function initJobs() {
|
|
| 29 |
|
| 30 |
// Retry Omada voucher-group setup after boot/config changes.
|
| 31 |
setTimeout(runVoucherGroupSync, 10_000);
|
|
|
|
| 32 |
|
| 33 |
// Hourly
|
| 34 |
cron.schedule('0 * * * *', runVoucherGroupSync);
|
|
|
|
| 7 |
const suspendDevices = require('./suspendDevices.job');
|
| 8 |
const billingReminders = require('./billingReminders.job');
|
| 9 |
const syncVoucherGroups = require('./syncVoucherGroups.job');
|
| 10 |
+
const syncPortalTemplates = require('./syncPortalTemplates.job');
|
| 11 |
|
| 12 |
function runVoucherGroupSync() {
|
| 13 |
syncVoucherGroups().catch(err => {
|
|
|
|
| 15 |
});
|
| 16 |
}
|
| 17 |
|
| 18 |
+
function runPortalTemplateSync() {
|
| 19 |
+
syncPortalTemplates().catch(err => {
|
| 20 |
+
console.warn('[portal-template] background sync failed:', err.message);
|
| 21 |
+
});
|
| 22 |
+
}
|
| 23 |
+
|
| 24 |
// adoptDevices — triggered on-demand from POST /api/devices/:id/adopt (not a cron job)
|
| 25 |
// pollSessions — browser triggers every 1 min while dashboard is open (throttled server-side);
|
| 26 |
// cron below is the fallback when no dashboard is open
|
|
|
|
| 36 |
|
| 37 |
// Retry Omada voucher-group setup after boot/config changes.
|
| 38 |
setTimeout(runVoucherGroupSync, 10_000);
|
| 39 |
+
setTimeout(runPortalTemplateSync, 20_000);
|
| 40 |
|
| 41 |
// Hourly
|
| 42 |
cron.schedule('0 * * * *', runVoucherGroupSync);
|
src/jobs/syncPortalTemplates.job.js
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
const db = require('../config/db');
|
| 2 |
+
const omada = require('../services/omada');
|
| 3 |
+
|
| 4 |
+
async function syncPortalTemplates() {
|
| 5 |
+
if (!omada.isOpenApiConfigured()) {
|
| 6 |
+
return;
|
| 7 |
+
}
|
| 8 |
+
|
| 9 |
+
const devices = await db.query(
|
| 10 |
+
`SELECT id, omada_site_id, omada_portal_id, omada_ssid_id
|
| 11 |
+
FROM devices
|
| 12 |
+
WHERE omada_site_id IS NOT NULL
|
| 13 |
+
AND omada_site_id <> ''
|
| 14 |
+
AND omada_portal_id IS NOT NULL
|
| 15 |
+
AND omada_portal_id <> ''
|
| 16 |
+
AND omada_ssid_id IS NOT NULL
|
| 17 |
+
AND omada_ssid_id <> ''
|
| 18 |
+
ORDER BY id ASC
|
| 19 |
+
LIMIT 50`
|
| 20 |
+
);
|
| 21 |
+
|
| 22 |
+
if (!devices.length) {
|
| 23 |
+
return;
|
| 24 |
+
}
|
| 25 |
+
|
| 26 |
+
console.log(`[portal-template] Syncing ${devices.length} Omada captive portal page(s)`);
|
| 27 |
+
|
| 28 |
+
for (const device of devices) {
|
| 29 |
+
try {
|
| 30 |
+
const imported = await omada.importAndAttachPortalPage(
|
| 31 |
+
device.omada_site_id,
|
| 32 |
+
device.omada_portal_id,
|
| 33 |
+
device.omada_ssid_id
|
| 34 |
+
);
|
| 35 |
+
if (imported?.importedPortalPageId) {
|
| 36 |
+
await db.query(
|
| 37 |
+
`UPDATE devices SET omada_imported_portal_page_id = ? WHERE id = ?`,
|
| 38 |
+
[imported.importedPortalPageId, device.id]
|
| 39 |
+
);
|
| 40 |
+
}
|
| 41 |
+
console.log(`[portal-template] device=${device.id} imported=${imported?.importedPortalPageId || 'none'}`);
|
| 42 |
+
} catch (err) {
|
| 43 |
+
console.warn(`[portal-template] sync failed for device ${device.id}:`, err.message);
|
| 44 |
+
}
|
| 45 |
+
}
|
| 46 |
+
}
|
| 47 |
+
|
| 48 |
+
module.exports = syncPortalTemplates;
|
src/routes/plans.routes.js
CHANGED
|
@@ -176,17 +176,61 @@ router.put('/:id', async (req, res) => {
|
|
| 176 |
});
|
| 177 |
|
| 178 |
// DELETE /api/plans/:id (soft delete — deactivate)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 179 |
router.delete('/:id', async (req, res) => {
|
| 180 |
try {
|
| 181 |
-
const plan = await db.
|
| 182 |
-
'SELECT p.id FROM wifi_plans p JOIN devices d ON d.id = p.device_id WHERE p.id = ? AND d.client_id = ? LIMIT 1',
|
| 183 |
[req.params.id, req.client.id]
|
| 184 |
-
)
|
| 185 |
if (!plan) return res.status(404).json({ error: 'Plan not found' });
|
| 186 |
|
| 187 |
-
|
| 188 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 189 |
} catch (err) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 190 |
res.status(500).json({ error: 'Failed to delete plan' });
|
| 191 |
}
|
| 192 |
});
|
|
@@ -204,22 +248,12 @@ router.delete('/:id/permanent', async (req, res) => {
|
|
| 204 |
);
|
| 205 |
if (!plan) return res.status(404).json({ error: 'Plan not found' });
|
| 206 |
|
| 207 |
-
const
|
| 208 |
-
|
| 209 |
-
(SELECT COUNT(*) FROM payments WHERE plan_id = ?) AS payment_refs,
|
| 210 |
-
(SELECT COUNT(*) FROM access_tokens WHERE plan_id = ?) AS token_refs`,
|
| 211 |
-
[plan.id, plan.id]
|
| 212 |
-
);
|
| 213 |
-
|
| 214 |
-
if ((refs.payment_refs || 0) > 0 || (refs.token_refs || 0) > 0) {
|
| 215 |
-
return res.status(409).json({
|
| 216 |
-
error: 'Plan has sales or tokens attached and cannot be permanently deleted',
|
| 217 |
-
});
|
| 218 |
-
}
|
| 219 |
-
|
| 220 |
-
await db.query('DELETE FROM wifi_plans WHERE id = ? AND client_id = ?', [plan.id, req.client.id]);
|
| 221 |
-
res.json({ message: 'Plan permanently deleted' });
|
| 222 |
} catch (err) {
|
|
|
|
|
|
|
|
|
|
| 223 |
console.error('[plans/permanent-delete]', err.message);
|
| 224 |
res.status(500).json({ error: 'Failed to permanently delete plan' });
|
| 225 |
}
|
|
|
|
| 176 |
});
|
| 177 |
|
| 178 |
// DELETE /api/plans/:id (soft delete — deactivate)
|
| 179 |
+
async function deletePlanRow(plan, { force = false } = {}) {
|
| 180 |
+
const refs = await db.queryOne(
|
| 181 |
+
`SELECT
|
| 182 |
+
(SELECT COUNT(*) FROM payments WHERE plan_id = ?) AS payment_refs,
|
| 183 |
+
(SELECT COUNT(*) FROM access_tokens WHERE plan_id = ?) AS token_refs`,
|
| 184 |
+
[plan.id, plan.id]
|
| 185 |
+
);
|
| 186 |
+
|
| 187 |
+
const paymentRefs = Number(refs?.payment_refs || 0);
|
| 188 |
+
const tokenRefs = Number(refs?.token_refs || 0);
|
| 189 |
+
if (paymentRefs > 0 || tokenRefs > 0) {
|
| 190 |
+
if (!force) {
|
| 191 |
+
const err = new Error('Plan has sales or tokens attached and cannot be permanently deleted');
|
| 192 |
+
err.status = 409;
|
| 193 |
+
err.refs = { payment_refs: paymentRefs, token_refs: tokenRefs };
|
| 194 |
+
throw err;
|
| 195 |
+
}
|
| 196 |
+
await db.query('UPDATE wifi_plans SET is_active = 0 WHERE id = ? AND client_id = ?', [plan.id, plan.client_id]);
|
| 197 |
+
return {
|
| 198 |
+
mode: 'deactivated',
|
| 199 |
+
refs: { payment_refs: paymentRefs, token_refs: tokenRefs },
|
| 200 |
+
};
|
| 201 |
+
}
|
| 202 |
+
|
| 203 |
+
await db.query('DELETE FROM wifi_plans WHERE id = ? AND client_id = ?', [plan.id, plan.client_id]);
|
| 204 |
+
return {
|
| 205 |
+
mode: 'deleted',
|
| 206 |
+
refs: { payment_refs: paymentRefs, token_refs: tokenRefs },
|
| 207 |
+
};
|
| 208 |
+
}
|
| 209 |
+
|
| 210 |
router.delete('/:id', async (req, res) => {
|
| 211 |
try {
|
| 212 |
+
const plan = await db.queryOne(
|
| 213 |
+
'SELECT p.id, p.client_id FROM wifi_plans p JOIN devices d ON d.id = p.device_id WHERE p.id = ? AND d.client_id = ? LIMIT 1',
|
| 214 |
[req.params.id, req.client.id]
|
| 215 |
+
);
|
| 216 |
if (!plan) return res.status(404).json({ error: 'Plan not found' });
|
| 217 |
|
| 218 |
+
const result = await deletePlanRow(plan, {
|
| 219 |
+
force: req.query.force === '1' || req.query.force === 'true',
|
| 220 |
+
});
|
| 221 |
+
res.json({
|
| 222 |
+
message: result.mode === 'deleted' ? 'Plan permanently deleted' : 'Plan has history and was deactivated',
|
| 223 |
+
...result,
|
| 224 |
+
});
|
| 225 |
} catch (err) {
|
| 226 |
+
if (err.status === 409) {
|
| 227 |
+
return res.status(409).json({
|
| 228 |
+
error: err.message,
|
| 229 |
+
refs: err.refs,
|
| 230 |
+
hint: 'Use DELETE /api/plans/:id?force=1 to deactivate plans that already have sales or tokens.',
|
| 231 |
+
});
|
| 232 |
+
}
|
| 233 |
+
console.error('[plans/delete]', err.message);
|
| 234 |
res.status(500).json({ error: 'Failed to delete plan' });
|
| 235 |
}
|
| 236 |
});
|
|
|
|
| 248 |
);
|
| 249 |
if (!plan) return res.status(404).json({ error: 'Plan not found' });
|
| 250 |
|
| 251 |
+
const result = await deletePlanRow(plan, { force: false });
|
| 252 |
+
res.json({ message: 'Plan permanently deleted', ...result });
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 253 |
} catch (err) {
|
| 254 |
+
if (err.status === 409) {
|
| 255 |
+
return res.status(409).json({ error: err.message, refs: err.refs });
|
| 256 |
+
}
|
| 257 |
console.error('[plans/permanent-delete]', err.message);
|
| 258 |
res.status(500).json({ error: 'Failed to permanently delete plan' });
|
| 259 |
}
|
src/routes/portal.routes.js
CHANGED
|
@@ -461,7 +461,7 @@ router.post('/:siteId/auth', portalAuthLimiter, async (req, res) => {
|
|
| 461 |
}
|
| 462 |
|
| 463 |
const mac = clientMac.toUpperCase().replace(/:/g, '-');
|
| 464 |
-
const normalizedCode = code.
|
| 465 |
const trace = createAuthTrace({ siteId, mac, code: normalizedCode });
|
| 466 |
|
| 467 |
try {
|
|
@@ -471,7 +471,7 @@ router.post('/:siteId/auth', portalAuthLimiter, async (req, res) => {
|
|
| 471 |
`SELECT t.*, d.omada_site_id
|
| 472 |
FROM access_tokens t
|
| 473 |
JOIN devices d ON d.id = t.device_id
|
| 474 |
-
WHERE t.code = ? AND d.omada_site_id = ? LIMIT 1`,
|
| 475 |
[normalizedCode, siteId]
|
| 476 |
).then(r => r[0]);
|
| 477 |
trace.step('token_lookup_complete', token ? {
|
|
|
|
| 461 |
}
|
| 462 |
|
| 463 |
const mac = clientMac.toUpperCase().replace(/:/g, '-');
|
| 464 |
+
const normalizedCode = String(code).trim();
|
| 465 |
const trace = createAuthTrace({ siteId, mac, code: normalizedCode });
|
| 466 |
|
| 467 |
try {
|
|
|
|
| 471 |
`SELECT t.*, d.omada_site_id
|
| 472 |
FROM access_tokens t
|
| 473 |
JOIN devices d ON d.id = t.device_id
|
| 474 |
+
WHERE BINARY t.code = ? AND d.omada_site_id = ? LIMIT 1`,
|
| 475 |
[normalizedCode, siteId]
|
| 476 |
).then(r => r[0]);
|
| 477 |
trace.step('token_lookup_complete', token ? {
|
src/views/screens/portal.ejs
CHANGED
|
@@ -779,7 +779,7 @@
|
|
| 779 |
<div class="manual-pay-head">
|
| 780 |
<div>
|
| 781 |
<h3>Pay the business directly</h3>
|
| 782 |
-
<p>Use the number below, then show payment confirmation and get your
|
| 783 |
</div>
|
| 784 |
<div class="manual-pay-badge"><%= String(paymentProvider || '').toUpperCase() %></div>
|
| 785 |
</div>
|
|
@@ -806,14 +806,14 @@
|
|
| 806 |
<div class="manual-pay-steps">
|
| 807 |
<div class="manual-pay-step"><span class="step-no">1</span><span>Choose your plan from this page.</span></div>
|
| 808 |
<div class="manual-pay-step"><span class="step-no">2</span><span>Pay the business using the merchant ID above.</span></div>
|
| 809 |
-
<div class="manual-pay-step"><span class="step-no">3</span><span>
|
| 810 |
</div>
|
| 811 |
</div>
|
| 812 |
</div>
|
| 813 |
<% } %>
|
| 814 |
|
| 815 |
<div class="divider" <% if (!showOnlinePayment) { %>style="display:none;"<% } %>><span>Pay via Mobile Money</span></div>
|
| 816 |
-
<p class="payment-note" <% if (!showOnlinePayment) { %>style="display:none;"<% } %>>Prefer instant activation? Enter your own number below to pay online and receive
|
| 817 |
|
| 818 |
<div class="input-wrap" <% if (!showOnlinePayment) { %>style="display:none;"<% } %>>
|
| 819 |
<label class="field-label" for="phone-input">Phone Number</label>
|
|
@@ -833,7 +833,7 @@
|
|
| 833 |
|
| 834 |
<% if (!showOnlinePayment) { %>
|
| 835 |
<div class="quick-access-note" style="margin-top:18px;">
|
| 836 |
-
This hotspot is currently configured for direct business payment only. Pay the business above and
|
| 837 |
</div>
|
| 838 |
<% } %>
|
| 839 |
|
|
@@ -844,9 +844,9 @@
|
|
| 844 |
<span class="token-entry-cta-title">Enter an existing code</span>
|
| 845 |
<span class="token-entry-cta-copy">
|
| 846 |
<% if (showDirectPayment) { %>
|
| 847 |
-
Paid the business already?
|
| 848 |
<% } else { %>
|
| 849 |
-
Returning customer? Reuse your
|
| 850 |
<% } %>
|
| 851 |
</span>
|
| 852 |
</span>
|
|
@@ -860,7 +860,7 @@
|
|
| 860 |
|
| 861 |
<% if (showDirectPayment) { %>
|
| 862 |
<div class="quick-access-note">
|
| 863 |
-
Already paid the business directly? Ask for your
|
| 864 |
</div>
|
| 865 |
<% } %>
|
| 866 |
<% if (portal.customize.supportPhone) { %>
|
|
@@ -885,8 +885,8 @@
|
|
| 885 |
<!-- SCREEN 3: Code entry (reconnect) -->
|
| 886 |
<div id="screen-code" class="screen">
|
| 887 |
<div class="input-wrap">
|
| 888 |
-
<label class="field-label" for="code-input">
|
| 889 |
-
<input class="arch-input code-style" type="text" id="code-input" placeholder="
|
| 890 |
</div>
|
| 891 |
<div class="error-msg" id="code-error"></div>
|
| 892 |
<button class="btn-primary" id="code-submit-btn">Authenticate</button>
|
|
@@ -898,7 +898,7 @@
|
|
| 898 |
<div class="success-badge">Connected</div>
|
| 899 |
<h2 class="success-headline">You're online.</h2>
|
| 900 |
<div class="code-panel">
|
| 901 |
-
<span class="field-label">Your
|
| 902 |
<div class="code-value" id="success-code">—</div>
|
| 903 |
</div>
|
| 904 |
<div class="meta-grid" id="success-meta"></div>
|
|
|
|
| 779 |
<div class="manual-pay-head">
|
| 780 |
<div>
|
| 781 |
<h3>Pay the business directly</h3>
|
| 782 |
+
<p>Use the number below, then show payment confirmation and get your Omada voucher code from the attendant.</p>
|
| 783 |
</div>
|
| 784 |
<div class="manual-pay-badge"><%= String(paymentProvider || '').toUpperCase() %></div>
|
| 785 |
</div>
|
|
|
|
| 806 |
<div class="manual-pay-steps">
|
| 807 |
<div class="manual-pay-step"><span class="step-no">1</span><span>Choose your plan from this page.</span></div>
|
| 808 |
<div class="manual-pay-step"><span class="step-no">2</span><span>Pay the business using the merchant ID above.</span></div>
|
| 809 |
+
<div class="manual-pay-step"><span class="step-no">3</span><span>Enter the voucher code exactly as shown to connect.</span></div>
|
| 810 |
</div>
|
| 811 |
</div>
|
| 812 |
</div>
|
| 813 |
<% } %>
|
| 814 |
|
| 815 |
<div class="divider" <% if (!showOnlinePayment) { %>style="display:none;"<% } %>><span>Pay via Mobile Money</span></div>
|
| 816 |
+
<p class="payment-note" <% if (!showOnlinePayment) { %>style="display:none;"<% } %>>Prefer instant activation? Enter your own number below to pay online and receive an Omada voucher automatically.</p>
|
| 817 |
|
| 818 |
<div class="input-wrap" <% if (!showOnlinePayment) { %>style="display:none;"<% } %>>
|
| 819 |
<label class="field-label" for="phone-input">Phone Number</label>
|
|
|
|
| 833 |
|
| 834 |
<% if (!showOnlinePayment) { %>
|
| 835 |
<div class="quick-access-note" style="margin-top:18px;">
|
| 836 |
+
This hotspot is currently configured for direct business payment only. Pay the business above and enter the Omada voucher code you receive.
|
| 837 |
</div>
|
| 838 |
<% } %>
|
| 839 |
|
|
|
|
| 844 |
<span class="token-entry-cta-title">Enter an existing code</span>
|
| 845 |
<span class="token-entry-cta-copy">
|
| 846 |
<% if (showDirectPayment) { %>
|
| 847 |
+
Paid the business already? Enter your Omada voucher code here to connect immediately.
|
| 848 |
<% } else { %>
|
| 849 |
+
Returning customer? Reuse your voucher code here instead of buying a new plan.
|
| 850 |
<% } %>
|
| 851 |
</span>
|
| 852 |
</span>
|
|
|
|
| 860 |
|
| 861 |
<% if (showDirectPayment) { %>
|
| 862 |
<div class="quick-access-note">
|
| 863 |
+
Already paid the business directly? Ask for your voucher, then use <strong>Enter an existing code</strong> to connect here.
|
| 864 |
</div>
|
| 865 |
<% } %>
|
| 866 |
<% if (portal.customize.supportPhone) { %>
|
|
|
|
| 885 |
<!-- SCREEN 3: Code entry (reconnect) -->
|
| 886 |
<div id="screen-code" class="screen">
|
| 887 |
<div class="input-wrap">
|
| 888 |
+
<label class="field-label" for="code-input">Omada Voucher Code</label>
|
| 889 |
+
<input class="arch-input code-style" type="text" id="code-input" placeholder="Enter voucher code" maxlength="32" autocomplete="one-time-code">
|
| 890 |
</div>
|
| 891 |
<div class="error-msg" id="code-error"></div>
|
| 892 |
<button class="btn-primary" id="code-submit-btn">Authenticate</button>
|
|
|
|
| 898 |
<div class="success-badge">Connected</div>
|
| 899 |
<h2 class="success-headline">You're online.</h2>
|
| 900 |
<div class="code-panel">
|
| 901 |
+
<span class="field-label">Your Omada Voucher Code - Save to Reconnect</span>
|
| 902 |
<div class="code-value" id="success-code">—</div>
|
| 903 |
</div>
|
| 904 |
<div class="meta-grid" id="success-meta"></div>
|