strapi

strapi - restrict user to fetch only data related to him

大兔子大兔子 提交于 2019-12-07 09:31:51
问题 Usually, a logged-in user gets all entries of a Content Type. I created a "snippets" content type (_id,name,content,users<<->>snippets) <<->> means "has and belongs to many" relation. I created some test users and make a request: curl -H 'Authorization: Bearer eyJ...' http://localhost:1337/snippets/ Main Problem: an authenticated user should only see the entries assigned to him. Instead, a logged-in user gets all snippets, which is bad. How is it possible to modify the fetchAll(ctx.query);

strapi - restrict user to fetch only data related to him

人走茶凉 提交于 2019-12-05 12:50:04
Usually, a logged-in user gets all entries of a Content Type. I created a "snippets" content type (_id,name,content,users<<->>snippets) <<->> means "has and belongs to many" relation. I created some test users and make a request: curl -H 'Authorization: Bearer eyJ...' http://localhost:1337/snippets/ Main Problem: an authenticated user should only see the entries assigned to him. Instead, a logged-in user gets all snippets, which is bad. How is it possible to modify the fetchAll(ctx.query); query to take that into account so it does something like fetchAll(ctx.state.user.id); at the / -route->

How to integrate Strapi API and Admin Panel with another node app (that consumes Strapi API)?

假如想象 提交于 2019-12-04 15:39:06
I'm trying to develop an app that uses Strapi Admin Panel api generation, and, at the same time, serves as a website that consumes this api. So, basically, I'm trying to build a website: where /api route servers as a Strapi API endpoint where /admin route serves as a Strapi Admin Panel for API creation where all the other routes are configured to serve my website, i.e.: / route is the landing page of my website /contacts is the contacts page etc. And, moreover, the static files of the website (html/css/etc) should be served from the server that, respectively, consumes the generated API (server