#authorization with data fetching

1 messages · Page 1 of 1 (latest)

cedar nacelle
#

Hi there, I was wondering what would be a good way to organize loader data.

e.g. in the scenario that I have a route called articles/$slug and I fetch the data in the articles.$slug.tsx route

now in the scenario where I have permission to view that article, but not edit it, is it possible to use the loader data there but block the user with a 404 because it doesn't make sense for them to goto the edit page

in the article data I have something like article.permissions.canEdit which will determine this

what are some suggestions if any dealing with this type of scenario?

urban radish
#

I would use the loader data on the react component to avoid showing the link/button to edit it

#

And in the edit route I would check if the user has permission and if it doesn’t I would return a 403

cedar nacelle
#

@urban radish for the edit route, would you just re-fetch the data in that routes loader to get accces to the permission data?