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

docs(tutorials/jokes): throw 403 instead of 401 if user is not the owner #4688

Merged
merged 3 commits into from
Nov 25, 2022
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions contributors.yml
Original file line number Diff line number Diff line change
Expand Up @@ -453,3 +453,4 @@
- zachdtaylor
- zainfathoni
- zhe
- chaukhoa97
2 changes: 1 addition & 1 deletion docs/tutorials/jokes.md
Original file line number Diff line number Diff line change
Expand Up @@ -4631,7 +4631,7 @@ Awesome! We're ready to handle errors and it didn't complicate our happy path on

Oh, and don't you love how just like with the `ErrorBoundary`, it's all contextual? So the rest of the app continues to function just as well. Another point for user experience 💪

You know what, while we're adding catch boundaries. Why don't we improve the `app/routes/jokes/$jokeId.tsx` route a bit by allowing users to delete the joke if they own it. If they don't, we can give them a 401 error in the catch boundary.
You know what, while we're adding catch boundaries. Why don't we improve the `app/routes/jokes/$jokeId.tsx` route a bit by allowing users to delete the joke if they own it. If they don't, we can give them a 403 error in the catch boundary. Unlike the 401 when the user needs to log in first, the 403 error means that although the user has been logged in, what he just attempt is forbidden (delete a joke that is not his).
chaukhoa97 marked this conversation as resolved.
Show resolved Hide resolved

One thing to keep in mind with `delete` is that HTML forms only support `method="get"` and `method="post"`. They don't support `method="delete"`. So to make sure our form will work with and without JavaScript, it's a good idea to do something like this:

Expand Down