Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to create user owned entities? #533

Open
justspamjustin opened this issue Jan 15, 2024 · 1 comment
Open

How to create user owned entities? #533

justspamjustin opened this issue Jan 15, 2024 · 1 comment
Labels

Comments

@justspamjustin
Copy link

justspamjustin commented Jan 15, 2024

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!

@chriskapp
Copy link
Member

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants