I wrote a small article on how to use current_user with coherence on Phoenix. There are already a couple of blogposts about it but I think it’s still worth sharing.
You already have
current_user in your
conn.assigns, so you can just use
@current_user in your views. Everything you manually pass to
render/3 in your controller will be merged with
conn.assigns before being passed to the view layer. There’s no need for assigning the user again in the controller action.
Also I see you’re using the “action overwrite” in controllers. I usually pass
[conn, conn.params, conn.assigns] to controller actions, so I can pattern match data out of assigns if the actions need some data for doing their job.
Thanks for the comment This use case for current_user is to use it explicitly in controller actions not in views (if that were the case then what you described is ofc the way to go). In this blogpost we passed the current_user var down from the controller to the view just as an example.
Isn’t coherence dead?
It’s not being as actively maintained, some people are moving to Pow.