Skip to content
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

Code execution continues when it should stop in POST action #407

Open
belmirp opened this issue Dec 19, 2018 · 1 comment
Open

Code execution continues when it should stop in POST action #407

belmirp opened this issue Dec 19, 2018 · 1 comment

Comments

@belmirp
Copy link

belmirp commented Dec 19, 2018

Hello.
If you try to post empty data via API, not React client application, the application will crash. The particular line in problem is in post.controller.js file, where you check if name, title or content are empty. The line:

res.status(403).end();

should abort execution. Possible solution could be:

return res.status(403).end();

but it raises eslint consistent-return warning.

@belmirp
Copy link
Author

belmirp commented Dec 20, 2018

The problem can be avoided by putting return on the next line:

res.status(403).end(); return;

And I am not sure whether 403 (unauthorized) is appropriate here, shouldn't be 400 when invalid data is sent?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant