Fixed QR code generation for 'Open' networks. Update README.md to reflect QR function. Updated dependencies

This commit is contained in:
Glenn de Haan
2025-01-08 19:09:25 +01:00
parent 4d2933b752
commit 4691a900c3
4 changed files with 12 additions and 8 deletions

View File

@@ -18,6 +18,7 @@ UniFi Voucher Site is a web-based platform for generating and managing UniFi net
- **Receipt Printing**: Supports printing vouchers with 80mm thermal printers.
- **Email Functionality**: Automatically send vouchers via SMTP.
- **Localized Email/Print Templates** Fully localized templates, with support for multiple languages.
- **Scan to Connect QR Codes** Quickly connect users via a phone's camera. (Available within Email and Print Layouts)
## Structure

View File

@@ -16,9 +16,12 @@ const variables = require('./variables');
* @return {Promise<unknown>}
*/
module.exports = (buffer = false) => {
// Define QR Content based on Wi-Fi Security Standard
const qrText = variables.unifiSsidPassword !== '' ? `WIFI:S:${variables.unifiSsid};T:WPA;P:${variables.unifiSsidPassword};;` : `WIFI:S:${variables.unifiSsid};;`;
return new Promise((resolve) => {
if(!buffer) {
QRCode.toDataURL(`WIFI:S:${variables.unifiSsid};T:${variables.unifiSsidPassword !== '' ? 'WPA' : ''};P:${variables.unifiSsidPassword !== '' ? variables.unifiSsidPassword : ''};;`, { version: 4, errorCorrectionLevel: 'Q' }, (err, url) => {
QRCode.toDataURL(qrText, { version: 4, errorCorrectionLevel: 'Q' }, (err, url) => {
if(err) {
log.error(`[Qr] Error while generating code!`);
log.error(err);
@@ -27,7 +30,7 @@ module.exports = (buffer = false) => {
resolve(url);
});
} else {
QRCode.toBuffer(`WIFI:S:${variables.unifiSsid};T:${variables.unifiSsidPassword !== '' ? 'WPA' : ''};P:${variables.unifiSsidPassword !== '' ? variables.unifiSsidPassword : ''};;`, { version: 4, errorCorrectionLevel: 'Q' }, (err, buffer) => {
QRCode.toBuffer(qrText, { version: 4, errorCorrectionLevel: 'Q' }, (err, buffer) => {
if(err) {
log.error(`[Qr] Error while generating code!`);
log.error(err);

10
package-lock.json generated
View File

@@ -24,7 +24,7 @@
"qrcode": "^1.5.4"
},
"devDependencies": {
"@tailwindcss/forms": "^0.5.9",
"@tailwindcss/forms": "^0.5.10",
"nodemon": "^3.1.9",
"tailwindcss": "^3.4.17"
},
@@ -320,16 +320,16 @@
}
},
"node_modules/@tailwindcss/forms": {
"version": "0.5.9",
"resolved": "https://registry.npmjs.org/@tailwindcss/forms/-/forms-0.5.9.tgz",
"integrity": "sha512-tM4XVr2+UVTxXJzey9Twx48c1gcxFStqn1pQz0tRsX8o3DvxhN5oY5pvyAbUx7VTaZxpej4Zzvc6h+1RJBzpIg==",
"version": "0.5.10",
"resolved": "https://registry.npmjs.org/@tailwindcss/forms/-/forms-0.5.10.tgz",
"integrity": "sha512-utI1ONF6uf/pPNO68kmN1b8rEwNXv3czukalo8VtJH8ksIkZXr3Q3VYudZLkCsDd4Wku120uF02hYK25XGPorw==",
"dev": true,
"license": "MIT",
"dependencies": {
"mini-svg-data-uri": "^1.2.3"
},
"peerDependencies": {
"tailwindcss": ">=3.0.0 || >= 3.0.0-alpha.1 || >= 4.0.0-alpha.20"
"tailwindcss": ">=3.0.0 || >= 3.0.0-alpha.1 || >= 4.0.0-alpha.20 || >= 4.0.0-beta.1"
}
},
"node_modules/@types/cacheable-request": {

View File

@@ -38,7 +38,7 @@
"qrcode": "^1.5.4"
},
"devDependencies": {
"@tailwindcss/forms": "^0.5.9",
"@tailwindcss/forms": "^0.5.10",
"nodemon": "^3.1.9",
"tailwindcss": "^3.4.17"
}