Updated kiosk.json with new translation strings. Updated info.js to reflect the multiple kiosk voucher types. Deprecated the KIOSK_VOUCHER_TYPE environment variable. Implemented the KIOSK_VOUCHER_TYPES environment variable with support for multiple voucher types. Moved the kiosk images (logo.png and bg.jpg) to a kiosk image sub-folder. Redesign of the kiosk.ejs language selector to provide space for custom images. Implemented voucher types within kiosk.ejs. Utilize the bytes converter within voucher.ejs to reformat bytes labels. Updated the docker-compose.yml. Updated the README.md. Implemented /kiosk custom assets overrides. Implemented a type check for the voucher types from kiosk requests

This commit is contained in:
Glenn de Haan
2025-07-09 18:57:32 +02:00
parent c8c3b923b4
commit 454d92b861
11 changed files with 171 additions and 29 deletions

View File

@@ -1,6 +1,7 @@
/**
* Import base packages
*/
const fs = require('fs');
const os = require('os');
const crypto = require('crypto');
const express = require('express');
@@ -88,6 +89,13 @@ app.use((req, res, next) => {
next();
});
/**
* Override kiosk images dir if available
*/
if(fs.existsSync('/kiosk')) {
app.use('/images/kiosk', express.static('/kiosk'));
}
/**
* Serve static public dir
*/
@@ -155,6 +163,9 @@ if(variables.serviceWeb) {
baseUrl: req.headers['x-ingress-path'] ? req.headers['x-ingress-path'] : '',
error: req.flashMessage.type === 'error',
error_text: req.flashMessage.message || '',
timeConvert: time,
bytesConvert: bytes,
voucher_types: types(variables.kioskVoucherTypes),
kiosk_name_required: variables.kioskNameRequired
});
});
@@ -207,8 +218,15 @@ if(variables.serviceWeb) {
});
}
} else {
const typeCheck = (variables.kioskVoucherTypes).split(';').includes(req.body['voucher-type']);
if (!typeCheck) {
res.cookie('flashMessage', JSON.stringify({type: 'error', message: 'Unknown Type!'}), {httpOnly: true, expires: new Date(Date.now() + 24 * 60 * 60 * 1000)}).redirect(302, `${req.headers['x-ingress-path'] ? req.headers['x-ingress-path'] : ''}/kiosk`);
return;
}
// Create voucher code
const voucherCode = await unifi.create(types(variables.kioskVoucherType, true), 1, variables.kioskNameRequired ? req.body['voucher-note'] : null).catch((e) => {
const voucherCode = await unifi.create(types(req.body['voucher-type'], true), 1, variables.kioskNameRequired ? req.body['voucher-note'] : null).catch((e) => {
res.cookie('flashMessage', JSON.stringify({type: 'error', message: e}), {httpOnly: true, expires: new Date(Date.now() + 24 * 60 * 60 * 1000)}).redirect(302, `${req.headers['x-ingress-path'] ? req.headers['x-ingress-path'] : ''}/kiosk`);
});