Fork me on GitHub
#fulcro
<
2022-06-30
>
Toni Tuominen14:06:45

Hello. I have model with a User and Post entities. A Post belongs to a user. The user must log in to create a post. To model it I have a (defattr :post/user :ref). Now how do I setup my RAD form so that the logged in user is set as the user on the post? Or is it something that I must setup somewhere else? I am using the auth solution from the RAD demo.

1
tony.kay15:06:12

Save middleware is typically how I do it. The user will be in the session (which you have to set up on your server), and the pathom env can include anything. I set up the ring middleware to add the request to the pathom env (which has the ring session) and then use that in the save middleware to auto-add ownership to things that have tempids (are new) by type.

❤️ 1