Tom Workman | WIP exercise-authentication-authorization Assignment#13
Open
tworkman512 wants to merge 8 commits intopce-uw-jscript400:masterfrom
Open
Tom Workman | WIP exercise-authentication-authorization Assignment#13tworkman512 wants to merge 8 commits intopce-uw-jscript400:masterfrom
tworkman512 wants to merge 8 commits intopce-uw-jscript400:masterfrom
Conversation
Successfully creates first admin user.
bwreid
reviewed
Aug 11, 2019
Collaborator
bwreid
left a comment
There was a problem hiding this comment.
Looks on the right track! Just a few things left to do.
| if (!checkForUser) throw new Error(`User ${username} does not exist.`); | ||
|
|
||
| const user = await bcrypt.compare(password, checkForUser.password); | ||
| if (!user) throw new Error(`Password is invalid.`); |
Collaborator
There was a problem hiding this comment.
You'll want to keep these error messages the same, otherwise it's easier for someone to "guess" at a username. Having the same error message is more secure.
| // const error = new Error("User cannot be found."); | ||
| // error.message = 404; | ||
| // return next(error); | ||
| // } |
Collaborator
There was a problem hiding this comment.
I think the order you have this in is a bit wrong. First you'll want to check for a user, then you'll want to check to see whether or not that user is an admin.
| next(error) | ||
| console.error(e); | ||
| const message = | ||
| "Failure to create. Please check request body and try again."; |
Collaborator
There was a problem hiding this comment.
Having the right-hand assignment be on a different line works fine but looks a bit dicey.
| const response = await Book.findById(book._id).select('-__v') | ||
| const status = 200 | ||
| res.json({ status, response }) | ||
| await book.save(); |
Collaborator
There was a problem hiding this comment.
You'll want to include a user id as well when reserving a book.
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.