-
Notifications
You must be signed in to change notification settings - Fork 994
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
fix(docs): Fix & make verifyOwnership consistent #8596
fix(docs): Fix & make verifyOwnership consistent #8596
Conversation
Hey @drikusroor, the name change seems sensible and was probably just an oversight on our part, thanks! @cannikin confirming the name and signature are good? And @drikusroor for your second point, is it just that it's a matter of three lines vs one line for the conditional? I feel like that was also a stylistic choice we made for readability, but @cannikin can you confirm that for me too? |
Yeah those different names must have been an oversight on my part, whoops! I'm not sure what I was thinking in that export const updatePost = async ({ id, input }) => {
if (await adminPost({ id })) {
return db.post.update({
data: input,
where: { id },
})
} else {
throw new ForbiddenError("You don't have access to this post")
}
} Which might flow a little nicer? But do all the other errors actually short circuit? We should probably stick to that convention if that's the case. |
Hi @cannikin, thank you for your response. With regards to:
I agree, your alternative "flows" nicer. I'm not sure if all the other errors will short circuit here. For now, this is just an example that is better than the one in the current documentation.
What do you mean by this? Should the later |
Sorry, I just meant that if we have other errors in the tutorial that short circuit then this would should too. But if not, I would stick with the longer one that's a little easier to read (do the update in the |
Hey, sorry for the days of silence. I just wanted to let you know I've updated the |
Awesome, thank you! |
…redwood into codemod/replace-svg-as-components * 'codemod/replace-svg-as-components' of github.com:dac09/redwood: chore(deps): update react monorepo (redwoodjs#8677) chore(deps): update dependency postcss to v8.4.24 (redwoodjs#8675) chore(deps): update dependency esbuild to v0.18.6 (redwoodjs#8670) chore(deps): update dependency dependency-cruiser to v13.0.4 (redwoodjs#8674) chore(deps): update dependency autoprefixer to v10.4.14 (redwoodjs#8668) chore(deps): update dependency @clerk/clerk-react to v4.20.5 (redwoodjs#8672) Fix typos in documentation (redwoodjs#8659) fix(docs): Fix & make verifyOwnership consistent (redwoodjs#8596) chore(deps): update dependency vite to v4.1.5 [security] (redwoodjs#8671) fix(deps): update dependency react-hook-form to v7.45.0 (redwoodjs#8664) chore(studio): update tremor to v3 (redwoodjs#8645) fix(deps): update dependency webpack to v5.87.0 (redwoodjs#8549) fix(deps): update dependency dotenv to v16.3.1 (redwoodjs#8663) chore(deps): update dependency @clerk/clerk-react to v4.20.4 (redwoodjs#8662) fix(vite): Change config for mantine and chakra to use export default (redwoodjs#8639) fix(deps): update storybook monorepo to v7.0.22 (redwoodjs#8652) Fix failing v5 codemod for DevFatalErrorPage (redwoodjs#8661)
* fix(docs): Add arrow to arrow function * fix(docs): De-duplicate verifyOwnership & validateOwnership naming and params * docs: Fix erroneous updatePost method example, which returned true instead of db.post.update(...) --------- Co-authored-by: Rob Cameron <cannikin@fastmail.com>
Currently, Chapter 7 (Accessing currentUser in the API Side) introduces a helper function to check whether the
currentUser
"owns" the post it wants to modify. However, the helper function is referred to asverifyOwnership
and later asvalidateOwnership
.This PR aims to:
Also, before the function is introduced, an inline check is done (see here) which returns
true
instead of thedb.post.update(...)
result. We might want to convert that throw an early error, although it doesn't look very pretty.