I have f.e. User and Post models. User object has an id and Post object has owner id. I want to render the <Edit /> button just when User is the owner of the Post. What is the best way to do this?
Simply I can just get the current User id from database using one of my django's endpoints and check if (user.id === post.owner) but is it the best way?
Also how can I block or redirect users which are not the owner if someone of them open the editing site by link. Should I also simply check if if user.id === post.owner?
One extra question: I am storing my JWT tokens at the moment in the localStorage. What should I looking for if I want to hide it in my blowser (if I click F12, I can find it in Application tab)?
You could offload the checking to the Edit Component sending the user.id to it (it should have post.owner) then handling that inside the Edit component.
To avoid people directly accessing the edit link, there many different options to prevent or make it harder, here are two simple ones: