premieroctet / next-crud

Full-featured CRUD routes for Next.js

Home Page:https://next-crud.js.org

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Check ownership

darmane opened this issue · comments

Hi! Is there any reusable way to check if the owner of a record is the one doing the request?

I have a token in the request that gives me the user's id and I want to fetch a record before UPDATE, READ_ONE or DELETE to check if the id of the relation 'User' is the same of the one in the token.

I think the callback 'onRequest' is the way to go, but I'm having troubles to write a reusable function to check that. Any help will be appreciated! :)

I found a way to handle it

🎉 Don't hesitate to share your solution here, it can help other people :)