Build a Family Movie Watchlist API - Build a Family Movie Watchlist API

Tell us what’s happening:

Greetings,
I am stuck at one task in this project and cannot really see why.
Here is the task:
When an authenticated user with the parent role makes a POST request to /api/watchlist/:userId/movies, the server should return a 201 status and add the movie to that user's watchlist.

Here is my code, so far: back-end-development-and-apis/build-a-family-movie-watchlist-api/routes/watchlist.js at main · henryotunuya/back-end-development-and-apis · GitHub

###Your project link(s)

solution: GitHub - henryotunuya/back-end-development-and-apis · GitHub

Your browser information:

User Agent is: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/155.0.0.0 Safari/537.36

Challenge Information:

Build a Family Movie Watchlist API - Build a Family Movie Watchlist API

GitHub Link: freeCodeCamp/curriculum/challenges/english/blocks/lab-family-movie-watchlist-api/6a55c79b579b9101d31815f7.md at main · freeCodeCamp/freeCodeCamp · GitHub

The problem seems to lie in my `authorizeModification` middleware. Here is the file: back-end-development-and-apis/build-a-family-movie-watchlist-api/middleware/authorize.js at main · henryotunuya/back-end-development-and-apis · GitHub

Someone please show me what I am doing wrong.

Looking at your authorizeModification() function, and I think the issue is with your logic. If I recall the demands of this project correctly, parent users should be able to modify the data of children users. Keeping that in mind, look at this line you have written, particularly the first clause:

if (req.user.role !== role && req.params.userId !== req.user.id)