mirror of
https://github.com/glenndehaan/unifi-voucher-site.git
synced 2026-04-05 00:43:44 -04:00
Implemented UNIFI_SSID_PASSWORD environment variable. Updated email template. Updated PDF template. Updated ESC/POS template. Updated README.md. Changed qr.js output based on open or password protected networks
This commit is contained in:
@@ -72,6 +72,8 @@ services:
|
|||||||
UNIFI_SITE_ID: 'default'
|
UNIFI_SITE_ID: 'default'
|
||||||
# The UniFi SSID where guests need to connect to (Used within templating and 'Scan to Connect')
|
# The UniFi SSID where guests need to connect to (Used within templating and 'Scan to Connect')
|
||||||
UNIFI_SSID: ''
|
UNIFI_SSID: ''
|
||||||
|
# The UniFi SSID WPA/WPA2/WPA3 Password (Can be ignored for 'Open' networks) (Used within templating and 'Scan to Connect')
|
||||||
|
UNIFI_SSID_PASSWORD: ''
|
||||||
# The password used to log in to the voucher portal Web UI
|
# The password used to log in to the voucher portal Web UI
|
||||||
AUTH_PASSWORD: '0000'
|
AUTH_PASSWORD: '0000'
|
||||||
# The Bearer token used for the API
|
# The Bearer token used for the API
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ services:
|
|||||||
UNIFI_PASSWORD: 'password'
|
UNIFI_PASSWORD: 'password'
|
||||||
UNIFI_SITE_ID: 'default'
|
UNIFI_SITE_ID: 'default'
|
||||||
UNIFI_SSID: ''
|
UNIFI_SSID: ''
|
||||||
|
UNIFI_SSID_PASSWORD: ''
|
||||||
AUTH_PASSWORD: '0000'
|
AUTH_PASSWORD: '0000'
|
||||||
AUTH_TOKEN: '00000000-0000-0000-0000-000000000000'
|
AUTH_TOKEN: '00000000-0000-0000-0000-000000000000'
|
||||||
AUTH_OIDC_ISSUER_BASE_URL: ''
|
AUTH_OIDC_ISSUER_BASE_URL: ''
|
||||||
|
|||||||
@@ -52,6 +52,7 @@ module.exports = {
|
|||||||
html: ejs.render(fs.readFileSync(`${__dirname}/../template/email/voucher.ejs`, 'utf-8'), {
|
html: ejs.render(fs.readFileSync(`${__dirname}/../template/email/voucher.ejs`, 'utf-8'), {
|
||||||
voucher,
|
voucher,
|
||||||
unifiSsid: variables.unifiSsid,
|
unifiSsid: variables.unifiSsid,
|
||||||
|
unifiSsidPassword: variables.unifiSsidPassword,
|
||||||
qr: await qr(),
|
qr: await qr(),
|
||||||
timeConvert: time,
|
timeConvert: time,
|
||||||
bytesConvert: bytes
|
bytesConvert: bytes
|
||||||
|
|||||||
@@ -76,14 +76,35 @@ module.exports = {
|
|||||||
.text(variables.unifiSsid, {
|
.text(variables.unifiSsid, {
|
||||||
continued: true
|
continued: true
|
||||||
});
|
});
|
||||||
doc.font('Helvetica')
|
|
||||||
.fontSize(10)
|
if(variables.unifiSsidPassword !== '') {
|
||||||
.text(` or,`);
|
doc.font('Helvetica')
|
||||||
|
.fontSize(10)
|
||||||
|
.text(`,`);
|
||||||
|
doc.font('Helvetica')
|
||||||
|
.fontSize(10)
|
||||||
|
.text(`Password: `, {
|
||||||
|
continued: true
|
||||||
|
});
|
||||||
|
doc.font('Helvetica-Bold')
|
||||||
|
.fontSize(10)
|
||||||
|
.text(variables.unifiSsidPassword, {
|
||||||
|
continued: true
|
||||||
|
});
|
||||||
|
doc.font('Helvetica')
|
||||||
|
.fontSize(10)
|
||||||
|
.text(` or,`);
|
||||||
|
} else {
|
||||||
|
doc.font('Helvetica')
|
||||||
|
.fontSize(10)
|
||||||
|
.text(` or,`);
|
||||||
|
}
|
||||||
|
|
||||||
doc.font('Helvetica')
|
doc.font('Helvetica')
|
||||||
.fontSize(10)
|
.fontSize(10)
|
||||||
.text(`Scan to connect:`);
|
.text(`Scan to connect:`);
|
||||||
|
|
||||||
doc.image(await qr(), 75, 205, {fit: [75, 75], align: 'center', valign: 'center'});
|
doc.image(await qr(), 75, variables.unifiSsidPassword !== '' ? 215 : 205, {fit: [75, 75], align: 'center', valign: 'center'});
|
||||||
doc.moveDown(6);
|
doc.moveDown(6);
|
||||||
|
|
||||||
doc.moveDown(2);
|
doc.moveDown(2);
|
||||||
@@ -197,8 +218,20 @@ module.exports = {
|
|||||||
printer.setTextSize(1, 1);
|
printer.setTextSize(1, 1);
|
||||||
printer.print(variables.unifiSsid);
|
printer.print(variables.unifiSsid);
|
||||||
printer.setTextNormal();
|
printer.setTextNormal();
|
||||||
printer.print(' or,');
|
if(variables.unifiSsidPassword) {
|
||||||
printer.newLine();
|
printer.print(',');
|
||||||
|
printer.newLine();
|
||||||
|
printer.print('Password: ');
|
||||||
|
printer.setTypeFontB();
|
||||||
|
printer.setTextSize(1, 1);
|
||||||
|
printer.print(variables.unifiSsidPassword);
|
||||||
|
printer.setTextNormal();
|
||||||
|
printer.print(' or,');
|
||||||
|
printer.newLine();
|
||||||
|
} else {
|
||||||
|
printer.print(' or,');
|
||||||
|
printer.newLine();
|
||||||
|
}
|
||||||
printer.println('Scan to connect:');
|
printer.println('Scan to connect:');
|
||||||
printer.alignCenter();
|
printer.alignCenter();
|
||||||
await printer.printImageBuffer(await qr(true));
|
await printer.printImageBuffer(await qr(true));
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ const variables = require('./variables');
|
|||||||
module.exports = (buffer = false) => {
|
module.exports = (buffer = false) => {
|
||||||
return new Promise((resolve) => {
|
return new Promise((resolve) => {
|
||||||
if(!buffer) {
|
if(!buffer) {
|
||||||
QRCode.toDataURL(`WIFI:S:${variables.unifiSsid};T:;P:;;`, { version: 4, errorCorrectionLevel: 'Q' }, (err, url) => {
|
QRCode.toDataURL(`WIFI:S:${variables.unifiSsid};T:${variables.unifiSsidPassword !== '' ? 'WPA' : ''};P:${variables.unifiSsidPassword !== '' ? variables.unifiSsidPassword : ''};;`, { version: 4, errorCorrectionLevel: 'Q' }, (err, url) => {
|
||||||
if(err) {
|
if(err) {
|
||||||
log.error(`[Qr] Error while generating code!`);
|
log.error(`[Qr] Error while generating code!`);
|
||||||
log.error(err);
|
log.error(err);
|
||||||
@@ -27,7 +27,7 @@ module.exports = (buffer = false) => {
|
|||||||
resolve(url);
|
resolve(url);
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
QRCode.toBuffer(`WIFI:S:${variables.unifiSsid};T:;P:;;`, { version: 4, errorCorrectionLevel: 'Q' }, (err, buffer) => {
|
QRCode.toBuffer(`WIFI:S:${variables.unifiSsid};T:${variables.unifiSsidPassword !== '' ? 'WPA' : ''};P:${variables.unifiSsidPassword !== '' ? variables.unifiSsidPassword : ''};;`, { version: 4, errorCorrectionLevel: 'Q' }, (err, buffer) => {
|
||||||
if(err) {
|
if(err) {
|
||||||
log.error(`[Qr] Error while generating code!`);
|
log.error(`[Qr] Error while generating code!`);
|
||||||
log.error(err);
|
log.error(err);
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ module.exports = {
|
|||||||
unifiPassword: config('unifi_password') || process.env.UNIFI_PASSWORD || 'password',
|
unifiPassword: config('unifi_password') || process.env.UNIFI_PASSWORD || 'password',
|
||||||
unifiSiteId: config('unifi_site_id') || process.env.UNIFI_SITE_ID || 'default',
|
unifiSiteId: config('unifi_site_id') || process.env.UNIFI_SITE_ID || 'default',
|
||||||
unifiSsid: config('unifi_ssid') || process.env.UNIFI_SSID || '',
|
unifiSsid: config('unifi_ssid') || process.env.UNIFI_SSID || '',
|
||||||
|
unifiSsidPassword: config('unifi_ssid_password') || process.env.UNIFI_SSID_PASSWORD || '',
|
||||||
voucherTypes: config('voucher_types') || process.env.VOUCHER_TYPES || '480,1,,,;',
|
voucherTypes: config('voucher_types') || process.env.VOUCHER_TYPES || '480,1,,,;',
|
||||||
voucherCustom: config('voucher_custom') !== null ? config('voucher_custom') : process.env.VOUCHER_CUSTOM ? process.env.VOUCHER_CUSTOM !== 'false' : true,
|
voucherCustom: config('voucher_custom') !== null ? config('voucher_custom') : process.env.VOUCHER_CUSTOM ? process.env.VOUCHER_CUSTOM !== 'false' : true,
|
||||||
serviceWeb: process.env.SERVICE_WEB ? process.env.SERVICE_WEB !== 'false' : true,
|
serviceWeb: process.env.SERVICE_WEB ? process.env.SERVICE_WEB !== 'false' : true,
|
||||||
|
|||||||
@@ -127,7 +127,12 @@
|
|||||||
<p style="font-family: sans-serif; font-size: 5px; margin: 0; margin-bottom: 5px;"> </p>
|
<p style="font-family: sans-serif; font-size: 5px; margin: 0; margin-bottom: 5px;"> </p>
|
||||||
<% if(unifiSsid !== '') { %>
|
<% if(unifiSsid !== '') { %>
|
||||||
<center>
|
<center>
|
||||||
<p style="font-family: sans-serif; font-size: 14px; font-weight: normal; margin: 0;">Connect to: <span style="font-weight: bold;"><%= unifiSsid %></span> or,</p>
|
<% if(unifiSsidPassword !== '') { %>
|
||||||
|
<p style="font-family: sans-serif; font-size: 14px; font-weight: normal; margin: 0;">Connect to: <span style="font-weight: bold;"><%= unifiSsid %></span>,</p>
|
||||||
|
<p style="font-family: sans-serif; font-size: 14px; font-weight: normal; margin: 0;">Password: <span style="font-weight: bold;"><%= unifiSsidPassword %></span> or,</p>
|
||||||
|
<% } else { %>
|
||||||
|
<p style="font-family: sans-serif; font-size: 14px; font-weight: normal; margin: 0;">Connect to: <span style="font-weight: bold;"><%= unifiSsid %></span> or,</p>
|
||||||
|
<% } %>
|
||||||
<p style="font-family: sans-serif; font-size: 14px; font-weight: normal; margin: 0;">Scan to connect:</p>
|
<p style="font-family: sans-serif; font-size: 14px; font-weight: normal; margin: 0;">Scan to connect:</p>
|
||||||
<img src="<%= qr %>" />
|
<img src="<%= qr %>" />
|
||||||
</center>
|
</center>
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ const variables = require('../modules/variables');
|
|||||||
* Util function to calculate paper size based on voucher data
|
* Util function to calculate paper size based on voucher data
|
||||||
*/
|
*/
|
||||||
module.exports = (voucher) => {
|
module.exports = (voucher) => {
|
||||||
let base = variables.unifiSsid !== '' ? 375 : 260;
|
let base = variables.unifiSsid !== '' ? variables.unifiSsidPassword !== '' ? 385 : 375 : 260;
|
||||||
|
|
||||||
if(voucher.qos_usage_quota) {
|
if(voucher.qos_usage_quota) {
|
||||||
base += 10;
|
base += 10;
|
||||||
|
|||||||
Reference in New Issue
Block a user