-
Notifications
You must be signed in to change notification settings - Fork 26
Feature/secure print #1836
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: dev
Are you sure you want to change the base?
Feature/secure print #1836
Conversation
| if(!user){ | ||
| throw new Error('user not found'); // checks user | ||
| } | ||
| if(!Number.isInteger(pagesToPrint) || pagesToPrint <= 0){ | ||
| throw new Error('invalid number'); | ||
| } | ||
| if (user.pagesPrinted < pagesToPrint) { | ||
| throw new Error('no pages remaining'); | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
instead of throwing an error just do logger.error here and return early, we dont have to return anything
api/main_endpoints/routes/Printer.js
Outdated
| const stream = await fs.promises.readFile(assembledPdfFromChunks); // buffer | ||
| const pdfDoc = await PDFDocument.load(stream); // load PDF | ||
| const numpages = pdfDoc.getPages().length; // get number of pages | ||
| const copiesInt = parseInt(copies || 1, 10); | ||
| const totalPages = numpages * copiesInt; | ||
| await subtractUserPages(user.id, totalPages); // updates users printcount |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
move this code in the existing try block in axios.post(PRINTER_URL ...
efar301
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
very good
No description provided.