-
Notifications
You must be signed in to change notification settings - Fork 2.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support --live to phx.gen.auth #4872
Conversation
Thanks for the amazing work! I've tested it a little and found a couple of small issues (besides a few typos above) in registration flow. Let me know if you want any help with it, I'll be happy to dig into the issues and contribute.
|
Thanks for the feedback @chvanikoff! I'll take a look to the live errors, I'll change how email and password are validated. In the case of the third point, I noticed that issue and asked Chris for help, but I still don't know what's going on and why the unit test I wrote doesn't show that error. What I've found so far is that when the parameters get to the session controller action, the password is an empty string. It would be very helpful if we can find out why this behavior happens. |
Just realised SettingsController is not ported to LiveView yet - Is it WIP, forgotten, not meant to be part of the PR, or not meant to be ported at all? :) |
@chvanikoff the |
id="login_form" | ||
:let={f} | ||
for={:<%= schema.singular %>} | ||
phx-change="validate" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should remove validate. :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
note to self, removing validate is pending on me with a new LV feature that maintains form state in the event of phx-change absence
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is great, I'm looking forward to having this available for new apps 😄
I'm wondering if mix phx.gen.auth --live
should generate a live session in the router for the authenticated routes so we can use live navigation? That will expose new users to that concept early in the app's development.
router_scope: router_scope(context), | ||
web_path_prefix: web_path_prefix(schema), | ||
test_case_options: test_case_options(ecto_adapter) | ||
test_case_options: test_case_options(ecto_adapter), | ||
live?: Keyword.fetch!(context.opts, :live) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you want to document this new flag above in the @moduledoc
? That way it should appear as an option when one runs mix help phx.gen.auth
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just documented it here: #5261
for={@password_changeset} | ||
action={Routes.<%= schema.route_helper %>_session_path(@socket, :create, %{_action: "password_updated"})} | ||
method="post" | ||
phx-change="validate_password" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks like I can update my password using the exact value of my current password. Is that something we should prevent?
Co-authored-by: José Valim <[email protected]>
Co-authored-by: José Valim <[email protected]>
Co-authored-by: Clay <[email protected]>
87d8b5e
to
9828643
Compare
Added --live option to
phx.gen.auth
command.With this new option, in addition to generating an authentication system with
Phoenix.View
s, you can also generate an authentication system usingLiveViews
.To generate an authentication system, the following options can be used:
--live
to generate a system withLiveView
--no-live
to generate a system withPhoenix.View
Additionally, if neither of these options is given, a prompt will be displayed so that the user can choose between these two options.
TODO
mix phx.gen.auth
if--live
and--no-live
is not present