mirror of
https://github.com/glenndehaan/unifi-voucher-site.git
synced 2026-03-31 06:24:02 -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'
|
||||
# The UniFi SSID where guests need to connect to (Used within templating and 'Scan to Connect')
|
||||
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
|
||||
AUTH_PASSWORD: '0000'
|
||||
# The Bearer token used for the API
|
||||
|
||||
@@ -11,6 +11,7 @@ services:
|
||||
UNIFI_PASSWORD: 'password'
|
||||
UNIFI_SITE_ID: 'default'
|
||||
UNIFI_SSID: ''
|
||||
UNIFI_SSID_PASSWORD: ''
|
||||
AUTH_PASSWORD: '0000'
|
||||
AUTH_TOKEN: '00000000-0000-0000-0000-000000000000'
|
||||
AUTH_OIDC_ISSUER_BASE_URL: ''
|
||||
|
||||
@@ -52,6 +52,7 @@ module.exports = {
|
||||
html: ejs.render(fs.readFileSync(`${__dirname}/../template/email/voucher.ejs`, 'utf-8'), {
|
||||
voucher,
|
||||
unifiSsid: variables.unifiSsid,
|
||||
unifiSsidPassword: variables.unifiSsidPassword,
|
||||
qr: await qr(),
|
||||
timeConvert: time,
|
||||
bytesConvert: bytes
|
||||
|
||||
@@ -76,14 +76,35 @@ module.exports = {
|
||||
.text(variables.unifiSsid, {
|
||||
continued: true
|
||||
});
|
||||
doc.font('Helvetica')
|
||||
.fontSize(10)
|
||||
.text(` or,`);
|
||||
|
||||
if(variables.unifiSsidPassword !== '') {
|
||||
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')
|
||||
.fontSize(10)
|
||||
.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(2);
|
||||
@@ -197,8 +218,20 @@ module.exports = {
|
||||
printer.setTextSize(1, 1);
|
||||
printer.print(variables.unifiSsid);
|
||||
printer.setTextNormal();
|
||||
printer.print(' or,');
|
||||
printer.newLine();
|
||||
if(variables.unifiSsidPassword) {
|
||||
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.alignCenter();
|
||||
await printer.printImageBuffer(await qr(true));
|
||||
|
||||
@@ -18,7 +18,7 @@ const variables = require('./variables');
|
||||
module.exports = (buffer = false) => {
|
||||
return new Promise((resolve) => {
|
||||
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) {
|
||||
log.error(`[Qr] Error while generating code!`);
|
||||
log.error(err);
|
||||
@@ -27,7 +27,7 @@ module.exports = (buffer = false) => {
|
||||
resolve(url);
|
||||
});
|
||||
} 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) {
|
||||
log.error(`[Qr] Error while generating code!`);
|
||||
log.error(err);
|
||||
|
||||
@@ -13,6 +13,7 @@ module.exports = {
|
||||
unifiPassword: config('unifi_password') || process.env.UNIFI_PASSWORD || 'password',
|
||||
unifiSiteId: config('unifi_site_id') || process.env.UNIFI_SITE_ID || 'default',
|
||||
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,,,;',
|
||||
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,
|
||||
|
||||
@@ -127,7 +127,12 @@
|
||||
<p style="font-family: sans-serif; font-size: 5px; margin: 0; margin-bottom: 5px;"> </p>
|
||||
<% if(unifiSsid !== '') { %>
|
||||
<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>
|
||||
<img src="<%= qr %>" />
|
||||
</center>
|
||||
|
||||
@@ -7,7 +7,7 @@ const variables = require('../modules/variables');
|
||||
* Util function to calculate paper size based on voucher data
|
||||
*/
|
||||
module.exports = (voucher) => {
|
||||
let base = variables.unifiSsid !== '' ? 375 : 260;
|
||||
let base = variables.unifiSsid !== '' ? variables.unifiSsidPassword !== '' ? 385 : 375 : 260;
|
||||
|
||||
if(voucher.qos_usage_quota) {
|
||||
base += 10;
|
||||
|
||||
Reference in New Issue
Block a user