mirror of
https://github.com/glenndehaan/unifi-voucher-site.git
synced 2026-03-31 06:24:00 -04:00
Fixed crash within QR generation for larger SSIDs and Passwords
This commit is contained in:
@@ -141,13 +141,18 @@ module.exports = {
|
||||
.fontSize(10)
|
||||
.text(`${t('scan')}:`);
|
||||
|
||||
doc.image(await qr(), 75, variables.unifiSsidPassword !== '' ? 215 : 205, {
|
||||
doc.image(await qr(), 75, variables.unifiSsidPassword !== '' ? 255 : 205, {
|
||||
fit: [75, 75],
|
||||
align: 'center',
|
||||
valign: 'center'
|
||||
});
|
||||
doc.moveDown(6);
|
||||
|
||||
// Check if we need to move the text down extra or not depending on if large SSIDs or Passwords are used
|
||||
if(variables.unifiSsidPassword !== '' && (variables.unifiSsidPassword.length < 16 || variables.unifiSsidPassword.length < 32)) {
|
||||
doc.moveDown(2);
|
||||
}
|
||||
|
||||
doc.moveDown(2);
|
||||
}
|
||||
|
||||
|
||||
@@ -21,7 +21,7 @@ module.exports = (buffer = false) => {
|
||||
|
||||
return new Promise((resolve) => {
|
||||
if(!buffer) {
|
||||
QRCode.toDataURL(qrText, { version: 4, errorCorrectionLevel: 'Q' }, (err, url) => {
|
||||
QRCode.toDataURL(qrText, { version: 6, errorCorrectionLevel: 'Q' }, (err, url) => {
|
||||
if(err) {
|
||||
log.error(`[Qr] Error while generating code!`);
|
||||
log.error(err);
|
||||
@@ -30,7 +30,7 @@ module.exports = (buffer = false) => {
|
||||
resolve(url);
|
||||
});
|
||||
} else {
|
||||
QRCode.toBuffer(qrText, { version: 4, errorCorrectionLevel: 'Q' }, (err, buffer) => {
|
||||
QRCode.toBuffer(qrText, { version: 6, errorCorrectionLevel: 'Q' }, (err, buffer) => {
|
||||
if(err) {
|
||||
log.error(`[Qr] Error while generating code!`);
|
||||
log.error(err);
|
||||
|
||||
@@ -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 !== '' ? variables.unifiSsidPassword !== '' ? 385 : 375 : 260;
|
||||
let base = variables.unifiSsid !== '' ? variables.unifiSsidPassword !== '' ? 415 : 375 : 260;
|
||||
|
||||
if(voucher.qos_usage_quota) {
|
||||
base += 10;
|
||||
|
||||
Reference in New Issue
Block a user