Ownership Check
noun
say it: “OH-ner-ship CHEK” /ˈoʊnərʃɪp tʃɛk/
A rule in an app that lets people change only the records that belong to them.
What is an ownership check?
An ownership check lets a user change a record only when it belongs to them. The API compares the record's owner with the signed-in user's id from their token, and answers 403 when they differ.
const review = await reviews.findOne({ _id: reviewId });
if (review.authorId !== req.user.id) {
return res.status(403).json({ error: "You can only edit your own reviews" });
}
In a sentence
- “The ownership check stopped Ben from editing Kim's review, although both are signed in.”
- “Every update and delete route needs an ownership check, not only a sign-in check.”
Level: Journeyman · More REST API terms at this level
Updated