Skip to content
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

Merged
merged 58 commits into from
Aug 1, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
58 commits
Select commit Hold shift + click to select a range
f012729
generate auth liveviews
bemesa21 Jun 9, 2022
0e2bdd0
conditionally inject liveview authentication code
bemesa21 Jun 17, 2022
4e0c2a1
add auth liveviews tests
bemesa21 Jun 21, 2022
e0aadaa
update failing tests
bemesa21 Jun 21, 2022
8d439cd
fix formatting issues
bemesa21 Jun 23, 2022
480b310
Apply suggestions from code review
bemesa21 Jun 23, 2022
2268c1c
Fix issue with login after registration
bemesa21 Jun 24, 2022
dfff0c9
Update priv/templates/phx.gen.auth/login_live.ex
chrismccord Jun 27, 2022
7e682d4
Replace user menu with function component
chrismccord Jun 29, 2022
87fff3e
show errors live, optionally validate email uniqueness
bemesa21 Jun 27, 2022
cae6dd3
format routes
bemesa21 Jun 30, 2022
cf902c0
generates settings liveview code
bemesa21 Jun 30, 2022
b992b37
generate confirmation liveview
bemesa21 Jun 30, 2022
0ed9d04
fix injection issues
bemesa21 Jun 30, 2022
93af377
rename tests, add doc
bemesa21 Jun 30, 2022
ade1ca5
fix format issues
bemesa21 Jun 30, 2022
5ffc22a
add missing settings live tests
bemesa21 Jun 30, 2022
551f997
change logic to generate files
bemesa21 Jun 30, 2022
4667bbd
fix formatted issues
bemesa21 Jun 30, 2022
c83d6df
fix failing tests
bemesa21 Jun 30, 2022
f573fab
Consolidate login controller
chrismccord Jul 4, 2022
9ce9260
Update tests and bring up to speed with LV 0.18
chrismccord Jul 4, 2022
6171477
formatting
chrismccord Jul 5, 2022
d7e42d8
Use submit_form LiveViewTest function
chrismccord Jul 5, 2022
3829dc9
Fix missing file
chrismccord Jul 5, 2022
beb3a40
Temporary assigns where applicable
chrismccord Jul 6, 2022
66c59fa
Dedup
chrismccord Jul 6, 2022
87be3fd
Docs
chrismccord Jul 6, 2022
abe3347
Simply registration changeset handling
chrismccord Jul 6, 2022
88d8a6b
Update lib/mix/phoenix/schema.ex
chrismccord Jul 6, 2022
d0f92ef
Kill unused function
chrismccord Jul 6, 2022
798df3c
Add forgot password Liveview
bemesa21 Jul 8, 2022
94e2cb6
remove unused function
bemesa21 Jul 8, 2022
28f8ef9
Add ConfirmationInstructionsLive and tests
bemesa21 Jul 8, 2022
36a786a
update test
bemesa21 Jul 8, 2022
b8d0bd9
Inject the user nav directly in layout
chrismccord Jul 13, 2022
03068c0
Fix tests
chrismccord Jul 13, 2022
546f009
Dry up padding indent
chrismccord Jul 13, 2022
03ba277
Update priv/templates/phx.gen.auth/session_controller.ex
chrismccord Jul 13, 2022
ddf497b
add live_session
bemesa21 Jul 13, 2022
9b6a5a5
handle email confirmation token in mount callback
bemesa21 Jul 13, 2022
80f940f
unique email is not validated until changes are applied
bemesa21 Jul 13, 2022
677af57
reasign password changeset
bemesa21 Jul 13, 2022
8c33b8f
apply format
bemesa21 Jul 13, 2022
edee13f
Update priv/templates/phx.gen.auth/schema.ex
bemesa21 Jul 13, 2022
10ad509
Add method to registration form
bemesa21 Jul 13, 2022
2f8283a
live errors for reset password form
bemesa21 Jul 13, 2022
8181717
fix failing test
bemesa21 Jul 13, 2022
0b004df
Remove phx-change from login form
chrismccord Jul 14, 2022
9b9cb9e
interactive prompt for LiveView generation
bemesa21 Jul 14, 2022
1c42da1
update integration tests
bemesa21 Jul 14, 2022
aeba900
update settings live
bemesa21 Jul 18, 2022
4a887b7
update mix.lock
bemesa21 Jul 20, 2022
b379eb8
Bump docs
chrismccord Jul 29, 2022
76278db
Touchup
chrismccord Jul 29, 2022
487b097
Update for verified routes
chrismccord Aug 1, 2022
9828643
Final touch ups
chrismccord Aug 1, 2022
de86e2a
update prompt message
bemesa21 Aug 1, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Dedup
  • Loading branch information
chrismccord authored and bemesa21 committed Aug 1, 2022
commit 66c59fa76a69d87e98786587e8cc7a18397b0e11
24 changes: 8 additions & 16 deletions lib/mix/tasks/phx.gen.auth/injector.ex
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,9 @@ defmodule Mix.Tasks.Phx.Gen.Auth.Injector do
app_layout_menu_inject_after_opening_body_tag(template_str, schema) do
[{:error, :unable_to_inject}]
else
:already_injected -> [:already_injected]
:already_injected ->
[:already_injected]

{:ok, new_tmpl} ->
[{:ok, {tmpl_path, new_tmpl}}, layout_view_inject({view_path, view_str}, schema, web_mod)]
end
Expand Down Expand Up @@ -175,19 +177,9 @@ defmodule Mix.Tasks.Phx.Gen.Auth.Injector do
defp layout_view_inject({view_path, content}, %Schema{} = schema, web_module) do
code = layout_view_code(schema, web_module)

if String.contains?(content, "def #{app_layout_menu_template_name(schema)}") do
:already_injected
else
new_view_file =
content
|> String.split("end")
|> Enum.drop(-1)
|> Enum.join("end")
|> Kernel.<>("\n")
|> Kernel.<>(code)
|> Kernel.<>("end")
|> Kernel.<>("\n")
{:ok, {view_path, new_view_file}}
case inject_before_final_end(content, code, "def #{app_layout_menu_template_name(schema)}") do
{:ok, new_view_file} -> {:ok, {view_path, new_view_file}}
:already_injected -> :already_injected
end
end

Expand Down Expand Up @@ -267,9 +259,9 @@ defmodule Mix.Tasks.Phx.Gen.Auth.Injector do
Injects snippet before the final end in a file
"""
@spec inject_before_final_end(String.t(), String.t()) :: {:ok, String.t()} | :already_injected
def inject_before_final_end(code, code_to_inject)
def inject_before_final_end(code, code_to_inject, search \\ nil)
when is_binary(code) and is_binary(code_to_inject) do
if String.contains?(code, code_to_inject) do
if String.contains?(code, search || code_to_inject) do
:already_injected
else
new_code =
Expand Down
1 change: 0 additions & 1 deletion test/mix/tasks/phx.gen.auth/injector_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ defmodule Mix.Tasks.Phx.Gen.Auth.InjectorTest do

@view_module_injected ~s'''
defmodule AppWeb.LayoutView do

def user_menu(assigns) do
~H"""
<ul>
Expand Down