Griffiths w5 pr#19
Open
crgriffiths wants to merge 2 commits into
Open
Conversation
bwreid
reviewed
Aug 10, 2019
bwreid
left a comment
Collaborator
There was a problem hiding this comment.
This looks excellent. Just a couple comments to note!
| const RouteError = (message, status) => { | ||
| this.message = message; | ||
| this.status = status; | ||
| } |
Collaborator
There was a problem hiding this comment.
Doesn't looks like this is getting used but... interesting start of an idea?
| const response = await User.create({ | ||
| username, | ||
| password: hashedPw, | ||
| admin |
Collaborator
There was a problem hiding this comment.
In general, you probably don't want to allow someone to make themselves an admin. For future apps, it's safer to not include this and require an account to be updated with admin permissions.
| return next(error) | ||
| } | ||
| const validated = bcrypt.compare(password, user.password) | ||
| if (!validated) throw new Error(`Username and password do not match`) |
Collaborator
There was a problem hiding this comment.
I would have the same message for both of the above errors. Otherwise, it is easier for someone to "guess" at a username/password combination.
| // You should only be able to reserve a book if a user is logged in | ||
| router.patch('/:id/reserve', async (req, res, next) => { | ||
| const { id } = req.params | ||
| const { bookId } = req.params |
Collaborator
There was a problem hiding this comment.
If you change this, you'll need to change the above route.
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
No description provided.