-
Notifications
You must be signed in to change notification settings - Fork 0
Staging #2
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: master
Are you sure you want to change the base?
Staging #2
Conversation
Gisonrg
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.
Please update according to comments.
Noted that don't wait for DB error to conclude that inputs are invalid.
| exports.updateUserSpritename = function(req, res) { | ||
| var query = { '_id': req.user._id }; | ||
| if (!req.body.spritename) { | ||
| res.send({ |
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.
Add a return here
Add a status code (400)
| error: "Please input new spritename for update" | ||
| }); | ||
| } | ||
| var updateAttributes = { "spritename":req.body.spritename } |
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.
Check not empty and limit the input length?
| updateAttributes['healthLimit'] = req.body.healthLimit | ||
| } | ||
| if (!updateAttributes.strength && !updateAttributes.stamina && !updateAttributes.agility && !updateAttributes.health && !updateAttributes.healthLimit) { | ||
| res.send({ |
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.
return, status code
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.
condition should be || (reject as long as one input is not correct)
Also, specify the condition explicitly (for example, must be >= 0)
| exports.updateUserSkills = function(req, res) { | ||
| var query = { '_id': req.user._id }; | ||
| if (!req.body.skills) { | ||
| res.send({ |
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.
return and status code, same for all codes below
| if (req.body.experience) { | ||
| updateAttributes['experience'] = req.body.experience | ||
| } | ||
| if (!updateAttributes.level && !updateAttributes.experience) { |
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.
- condition should be
||(no level or no experience) - if
level == 0,!levelwill be true. Write explicit condition
| // Get user | ||
| router.get('/users/:id', verifyToken, authCtrl.refreshToken, userCtrl.getUser); | ||
| // Update user | ||
| router.post('/users', verifyToken, authCtrl.refreshToken, userCtrl.updateUser); |
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.
Kept this method and its route for now. Not all users will upgrade to use Api v2.
No description provided.