diff --git a/modules/invoiceOut/back/methods/invoiceOut/downloadZip.js b/modules/invoiceOut/back/methods/invoiceOut/downloadZip.js index 65f1f8a955..834d3c0318 100644 --- a/modules/invoiceOut/back/methods/invoiceOut/downloadZip.js +++ b/modules/invoiceOut/back/methods/invoiceOut/downloadZip.js @@ -1,5 +1,6 @@ const JSZip = require('jszip'); const fs = require('fs-extra'); +const UserError = require('vn-loopback/util/user-error'); module.exports = Self => { Self.remoteMethodCtx('downloadZip', { @@ -34,7 +35,7 @@ module.exports = Self => { let totalSize = 0; const zipConfig = await models.ZipConfig.findOne(); for (let id of ids) { - if (zipConfig && totalSize > zipConfig.maxSize) return false; + if (zipConfig && totalSize > zipConfig.maxSize) throw new UserError('Files are too large'); const invoiceOutPdf = await models.InvoiceOut.download(ctx, id, myOptions); const fileName = extractFileName(invoiceOutPdf[2]); const body = invoiceOutPdf[0]; diff --git a/modules/invoiceOut/front/index/index.js b/modules/invoiceOut/front/index/index.js index f1d849710b..a460600739 100644 --- a/modules/invoiceOut/front/index/index.js +++ b/modules/invoiceOut/front/index/index.js @@ -1,6 +1,5 @@ import ngModule from '../module'; import Section from 'salix/components/section'; -const UserError = require('vn-loopback/util/user-error'); export default class Controller extends Section { get checked() { @@ -35,7 +34,6 @@ export default class Controller extends Section { }; this.$http.post(`InvoiceOuts/downloadZip`, params) .then(res => { - if (res.data == false) throw new UserError('Files are too large'); location.href = 'data:application/zip;base64,' + res.data; }); }