apioo / fusio

Open source API management platform

Home Page:https://www.fusio-project.org

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

How to create user owned entities?

justspamjustin opened this issue · comments

Hi,
I'm wanting to use fusio as the backend for an app that I'm developing. I can see that Fusio has users that can register and log in via the api. However, let's say for example that I'm creating a todo app and I have a table that contains the all the Todo items for every user in my app. But the end user should be restricted to only be able to do CRUD operations on the items with their user id.

How do I accomplish this using fusio? Do I need to write PHP code to get the current userId? Or is there a built-in feature for this use case? Are there any existing samples or documentation about this case?

Thank you!

Hi @justspamjustin,

yes this is easy possible but for this you would need to build a custom action in PHP. Basically this is really simple you can take a look at our documentation s.
https://docs.fusio-project.org/docs/use_cases/develop_custom_action

You can pass the user id of the context $context->getUser()->getId() to your table.

We have also an example app s. https://github.com/apioo/fusio-sample-cms which shows how to build a more complex backend app, there we also use this user id. You could also take a look at our APIgen project which provides a way to generate a complete backend API based on an entity definiton.