-
Notifications
You must be signed in to change notification settings - Fork 28
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
Open
Embotic-Wayne
wants to merge
22
commits into
dev
Choose a base branch
from
feature/secure-print
base: dev
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Feature/secure print #1836
Changes from 9 commits
Commits
Show all changes
22 commits
Select commit
Hold shift + click to select a range
3be08e1
Changed api to subtract users page count by corrected amount of pages…
Embotic-Wayne 11a4954
Spacing fix
Embotic-Wayne 0fbbd52
Removed printcount,changed subtractpages logic and used single buffer…
Embotic-Wayne 55ebd95
change subtractuserpages logic
Embotic-Wayne d646add
fix lint errors
Embotic-Wayne bb9d5e8
changed pdfparse to pdf lib
Embotic-Wayne c516838
Resolve conflict and update package.json
Embotic-Wayne c6b107a
reset package lock to dev
evanugarte 0b836b0
npm run server-install
evanugarte 827ceed
changed log errors and moved code into try block
Embotic-Wayne 1d86e57
Removed throws in subtractuserpages and added changed printerjs logic
Embotic-Wayne fcd86f2
moved form data
Embotic-Wayne 2c299ba
fix lint errors
Embotic-Wayne 182b1de
fix random lines
Embotic-Wayne 7d045cb
spacing fix
Embotic-Wayne 7cc4d01
spacing fix again
Embotic-Wayne adced20
lint error
Embotic-Wayne c6eadf5
Created more useful log messages and fixed printer logic
Embotic-Wayne c571754
Uninstalled redis from api
Embotic-Wayne 1222570
changed return type of subtractUserPages and used badrequest instead …
Embotic-Wayne 9e0bd99
lint errors
Embotic-Wayne d3dee1f
api test fix?
Embotic-Wayne File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -202,6 +202,23 @@ function checkIfPageCountResets(lastLogin) { | |
|
|
||
| return lastLoginWasOverOneWeekAgo || aSundayHasPassedSinceLastLogin; | ||
| } | ||
| // updates users available pages | ||
| async function subtractUserPages(userId, pagesToPrint){ | ||
| const user = await User.findById(userId); | ||
| 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'); | ||
| } | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 |
||
|
|
||
| user.pagesPrinted -= pagesToPrint; | ||
| await user.save(); | ||
| return user.pagesPrinted; | ||
| } | ||
|
|
||
| module.exports = { | ||
| registerUser, | ||
|
|
@@ -211,4 +228,5 @@ module.exports = { | |
| userWithEmailExists, | ||
| checkIfPageCountResets, | ||
| findPasswordReset, | ||
| subtractUserPages, | ||
| }; | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 ...