dave0
I’ve used mix phx.gen.auth to create an authentication system. Now the user session/reset password is part of the non-LiveView app while most authenticated points are “live”. The only exception is the UserSettings portion of the auth. I’d like these to be “live” as well.
The first thing I tried was moving the “update password” feature to live. So I made a LiveComponent to open a modal and, using phx-trigger-action, I can validate inside the LiveView component and then submit it to the UserSettingsController to handle clearing the session and re-logging in the user. Then it’ll kick me back to the live session.
This all works fine, but I can’t help wonder if there may be a security issue here.
-
Is it safe to send the new password this way?
-
When the form validates, it automatically clears the password fields. I then have to repopulate the values using
socket.assignsbefore submitting over HTTP. Is there an issue with having the passwords in theassignsor manually set using thevalueattribute?
Trending in Questions
Other Trending Topics
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #deployment
- #library
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #elixirconf
- #channels
- #exunit
- #discussion
- #code-sync
- #javascript
- #podcasts
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #blog-post
- #elixir-ls
- #elixirconf-us
- #ai
- #phoenix_html
- #iex
- #graphql
- #genstage
- #websockets
- #supervisor
- #advent-of-code
- #distillery
- #processes
- #api
- #forms
- #hex
- #security
- #metaprogramming











Showing Posts 1 to 2- Show Best Posts
- Show All (oldest first)
- Show All (newest first)
f0rest8
I think you might find this thread helpful.
I’m not totally following your question but your
change_password_component.html.leex(or equivalent) might look something similar to this:I’ve stripped out a lot, but the input_value/2 from Phoenix.HTML needs to be set on your password field.
And you use the
update/2callback for Phoenix.LiveComponent in yourchange_password_component.exfile (or equivalent):You’d also have
handle_event/3callbacks for"validate_password"and"update_password", or whatever you’d like to call those actions.I’m planning to add another Medium post on switching the settings page over to a Live View page as a continuation of my other two posts (which you can find in the aforementioned thread), and I will update @slouchpie’s thread accordingly.
Hope this helps
dave0
Thanks, that was very helpful. In the other thread, you mentioned how
bytepack_archivealso moved some stuff into LiveView and I was just looking at that archive. Great to know they’re doing the same things I was questioning in this thread.