POW authentication in Liveview. How?

I’ve tried to look for an answer for days but with my noob kung fu, I am getting nowhere. :frowning:

I am able to do the basics of installing, registering for new users etc. But how do I use this in Liveview, Components etc. without conn? Is there a straightforward way to do this or do I need to deep dive into different parts of the code to inject a bit of code here and a bit of code there to make things work together?

Let’s start with:-

  1. How do I pass the authenticated user ID over to Liveview (v0.18.18)?
  2. How do I log out of the session from Liveview?

According to Pow, I should do this to log out

<.link :if={Pow.Plug.current_user(@conn)} href={~p"/session"} method=“delete”>Sign out</.link>

How do I make this work inside Liveview?

Pow doesn’t officially support LiveView yet. But you can check the available documentation on this issue to make it work: Official documentation on how to use Pow with LiveView · Issue #663 · pow-auth/pow · GitHub.

2 Likes