Hi everyone,
What is the standard way to retrieve "current_user" in Liveview using POW?
I'm starting a project from scratch with LiveView and POW, and despite several topics discussing the problem, I can't find any documented solution or tutorial. Even less on recent versions.
My questions:
- To retrieve the current_user with POW, should I use
Pow.Plug.current_user() or Pow.Store.CredentialsCache.get()? What are the differences, and what is the modern method?
- From what I understand, as these two functions require a
conn, I have to create a plug with a put_session() function to add the current user ID -> Is there a recommended way to do this? Where should the plug be?
- Once the current user ID is in the session, do I have to
assign_new(socket, :current_user, Users.get_user(session["current_user_id"]) in the mount() of each LiveView? Or there's a more practical way to do it?
A guide on the subject, particularly in the docs, would be welcome.
Thanks for any help :)
Hi everyone,
What is the standard way to retrieve "current_user" in Liveview using POW?
I'm starting a project from scratch with LiveView and POW, and despite several topics discussing the problem, I can't find any documented solution or tutorial. Even less on recent versions.
My questions:
Pow.Plug.current_user()orPow.Store.CredentialsCache.get()? What are the differences, and what is the modern method?conn, I have to create a plug with aput_session()function to add the current user ID -> Is there a recommended way to do this? Where should the plug be?assign_new(socket, :current_user, Users.get_user(session["current_user_id"])in themount()of each LiveView? Or there's a more practical way to do it?A guide on the subject, particularly in the docs, would be welcome.
Thanks for any help :)