Ash.set_actor in a Plug in Liveview


I have a simple plug that guards my authenticated routes. Within the plug, I added in a line to set the actor for Ash, via Ash.set_actor.

It works fine for dead views. However, for liveviews, because the page is loaded twice, the actor information in Ash gets lost in the 2nd load.

Is there a workaround?


Are using ash_authentication / ash_authentication_phoenix? This guide has worked for me in the past to get auth working with live view.

Yep, you will need something along those lines (using live_session) to get an actor into your live views.