flmel
Hello Everyone,
I’m trying to make Pow register form validation trough LiveView which I more or less succeeded at. However, upon user creation pow normally would log the user trough the plug:
from pow docs
def create(conn, %{"user" => user_params}) do
conn
|> Pow.Plug.create_user(user_params)
|> case do
{:ok, user, conn} ->
conn
|> put_flash(:info, "Welcome!")
|> redirect(to: Routes.page_path(conn, :index))
...
end
My LiveView event currently looks like this (i had to create a custom function create_user in order to escape the conn needed for the Plug but now Im trying to figure out how to log in the user on creation…
def handle_event("save", %{"user" => user_params}, socket) do
case Accounts.create_user(user_params) do
{:ok, _user} ->
# Form is valid
{:stop,
socket
|> put_flash(:info, "user created")
|> redirect(to: Routes.live_path(socket, MyApp.SearchLive))}
..
So basically is there a way to pass the conn trough my liveview or i shall copy/write the entire functionality myself.
@danschultzer somewhere in the forum you’ve mentioned that you would put a demo with liveview did you ever get around to do that ?
Thanks for your time
Trending in Questions
Hello!
Suppose you are building workflow (order / task / payment) processing system with the following requirements:
Each workflow con...
New
I’m aware of 2 such projects, are there others?
git: GitHub - team-alembic/realworld: A fullstack Phoenix LiveView application with back...
New
Hi all,
I’m working on a Phoenix project where I need to make external HTTP requests and I’m trying to choose between Req and HTTPoison....
New
Hi everyone.
My team and I have been working on a fairly modest app based around video streaming and chat, but we’ve landed a customer t...
New
Hi,
we run different LLM models across a cluster, with each node loading a configurable subset. Model-specific queues let nodes consume ...
New
Hi all, I’m new here and would like to hear peoples views on my Elixir/Phoenix based game-engine! :smiley:
Mutonex gamedesign was finish...
New
Hello
I’ve been coding in Elixir for almost two years now because of my current job where we implemented Elixir in our application. But ...
New
Other Trending Topics
Hey there,
I haven’t seen a list of useful Elixir specific skills for the popular AI tools yet so I’m starting one here with my first.
...
New
I fully migrated to my own harness from Anthropic/Gemini and I think it’s time to share it. Welcome DSH, the DeepSeek Harness, fully writ...
New
Hey. Is there anyone here who creates agents in their apps? Not talking about using agents, but creating them. I’m finding it pretty diff...
New
Beam Bots (or just BB for short) is a framework for building fault-tolerant robotics applications in Elixir using familiar OTP patterns. ...
New
With AI doing more of the implementation work, I’ve been wondering how much coding I should deliberately keep doing myself.
My main conc...
New
(I just needed to vent somewhere and LinkedIn is full of hope, or hype, I’m not sure which exactly)
AI dream has many faces, but general...
New
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #library
- #deployment
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #elixirconf
- #channels
- #exunit
- #discussion
- #code-sync
- #podcasts
- #javascript
- #onsite
- #dialyzer
- #docker
- #authentication
- #ai
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #blog-post
- #ecto-query
- #elixirconf-us
- #elixir-ls
- #phoenix_html
- #iex
- #graphql
- #genstage
- #websockets
- #supervisor
- #advent-of-code
- #distillery
- #processes
- #elixirconf-eu
- #api
- #forms
- #security
- #hex










Showing Posts 1 to 10- Show Best Posts
- Show All (oldest first)
- Show All (newest first)
andreaseriksson
Why do you want this in a LiveView?
flmel
Very good question, this was a task given to me by a “mentor”. Initially I got that as to validate the form on the fly and I believe most of the app would move into liveview and the form would expand.
PS. looking into your profile its the first time i get to know about fullstackphoenix. Thank you for your time keeping this up
andreaseriksson
Thanks.
I can’t say for sure its a bad idea to have a live validation on the registration (or login) form but it seems overly complicated and could be a security risk. Especially if you check for if email is already used. I just can’t see the upside other than learning how it works behind the scenes.
Schultzer
I don’t want to ruin your learning experience but take a look at the pow/lib/pow/phoenix/controllers/registration_controller.ex at main · pow-auth/pow · GitHub
I would also go through this issue Instructions for WebSocket usage (e.g. Phoenix Channels and LiveView) · Issue #271 · pow-auth/pow · GitHub
The last thing you want to figure out is the differences between session and token based authentications and how to handle session based authentication in a LiveView socket.
danschultzer
You can’t set cookies in a WebSocket. You have to pass the session id value to the client and set up some custom JS client side that will set it as a cookie. There’s some security issues too. I would recommend that you only deal with auth in HTTP.
Haven’t gotten to it yet. I’m trying out a Pow implementation with Phoenix.Socket though, hopefully can take what I learn from that and add it to the Pow docs/code
flmel
Thank you everyone!
chrismccord
This is one of the usecases I have highlighted all along for where LV shines. Imagine a registration form where you necessarily want to improve UX because it directly increases conversions. You want to give the user feedback as soon as possible when they are trying to sign up, so realtime validations are essential, but LV allows you to add it without bringing int a client side solution and all the baggage that comes with it. The outstanding issues with a full LiveView signin or registration form is the cookie session writing on login or sign up. This can’t happen over websockts so folks have two options.
put_sessionput_sessionto write the sessionSo LV is can be used here without any of the mentioned security issues. You are of course free to use regular controllers if that’s a better fit
flmel
What I was thinking was just use the validation and post it to the pow custom controller. Thank you Chris. And exactly one of the reasons to use LV on such a simple task is the added “user value”.
Now that LV approaches v1 thanks to all the work you put in. I think it will be great to put some beginner friendly documentation. I hope I will get to the level being able to contribute back.
ondrej-tucek
You mean something like that?
andreaseriksson
Sure, I know how LV validations works. I was just imagine a more simple use case where you add email and password, since Pow was mentioned. And for that use case, I think LV is overkill.