Link data creation to current authentified user

  • Strapi Version: 3.5.4
  • Operating System: Windows 10
  • Database: SQL
  • Node Version: 3.5.4
  • Yarn Version: 1.22.10


I have a “Address” collection in which I have a relationship with my user collection, I would like that each new entry in the Address collection be directly linked to the user that created it, via his JWT, but I do not know exactly how to proceed, am I obliged to create a custom function in the Strapi code?

Hi @Oddwerth,

You can easily access to the user objecti on Authenticated endpoint thanks : ctx.state.user

After that you can create a custom controller based on the core controllers and just put inside the data the ID of the User who called the endpoint.

If you need more details about it: Is Owner - Strapi Developer Documentation

1 Like

Thanks for your reply, I’ll try that solution !

If this work for you can you mark it as a solution for all the people who can have this issue :wink: