diff --git a/lib/mix/tasks/phx.gen.auth.ex b/lib/mix/tasks/phx.gen.auth.ex index 4e29105736..04cb5d2348 100644 --- a/lib/mix/tasks/phx.gen.auth.ex +++ b/lib/mix/tasks/phx.gen.auth.ex @@ -274,69 +274,91 @@ defmodule Mix.Tasks.Phx.Gen.Auth do case Keyword.fetch(context.opts, :live) do {:ok, true} -> live_files = [ - "registration_live.ex": [web_pre, "live", web_path, "#{singular}_registration_live.ex"], + "registration_live.ex": [ + web_pre, + "live", + web_path, + "#{singular}_live", + "registration.ex" + ], "registration_live_test.exs": [ web_test_pre, "live", web_path, - "#{singular}_registration_live_test.exs" + "#{singular}_live", + "registration_test.exs" ], - "login_live.ex": [web_pre, "live", web_path, "#{singular}_login_live.ex"], + "login_live.ex": [web_pre, "live", web_path, "#{singular}_live", "login.ex"], "login_live_test.exs": [ web_test_pre, "live", web_path, - "#{singular}_login_live_test.exs" + "#{singular}_live", + "login_test.exs" ], "reset_password_live.ex": [ web_pre, "live", web_path, - "#{singular}_reset_password_live.ex" + "#{singular}_live", + "reset_password.ex" ], "reset_password_live_test.exs": [ web_test_pre, "live", web_path, - "#{singular}_reset_password_live_test.exs" + "#{singular}_live", + "reset_password_test.exs" ], "forgot_password_live.ex": [ web_pre, "live", web_path, - "#{singular}_forgot_password_live.ex" + "#{singular}_live", + "forgot_password.ex" ], "forgot_password_live_test.exs": [ web_test_pre, "live", web_path, - "#{singular}_forgot_password_live_test.exs" + "#{singular}_live", + "forgot_password_test.exs" ], - "settings_live.ex": [web_pre, "live", web_path, "#{singular}_settings_live.ex"], + "settings_live.ex": [web_pre, "live", web_path, "#{singular}_live", "settings.ex"], "settings_live_test.exs": [ web_test_pre, "live", web_path, - "#{singular}_settings_live_test.exs" + "#{singular}_live", + "settings_test.exs" + ], + "confirmation_live.ex": [ + web_pre, + "live", + web_path, + "#{singular}_live", + "confirmation.ex" ], - "confirmation_live.ex": [web_pre, "live", web_path, "#{singular}_confirmation_live.ex"], "confirmation_live_test.exs": [ web_test_pre, "live", web_path, - "#{singular}_confirmation_live_test.exs" + "#{singular}_live", + "confirmation_test.exs" ], "confirmation_instructions_live.ex": [ web_pre, "live", web_path, - "#{singular}_confirmation_instructions_live.ex" + "#{singular}_live", + "confirmation_instructions.ex" ], "confirmation_instructions_live_test.exs": [ web_test_pre, "live", web_path, - "#{singular}_confirmation_instructions_live_test.exs" + "#{singular}_live", + "confirmation_instructions_test.exs" ] ] diff --git a/priv/templates/phx.gen.auth/confirmation_instructions_live.ex b/priv/templates/phx.gen.auth/confirmation_instructions_live.ex index 2917a418f1..480c82d65c 100644 --- a/priv/templates/phx.gen.auth/confirmation_instructions_live.ex +++ b/priv/templates/phx.gen.auth/confirmation_instructions_live.ex @@ -1,4 +1,4 @@ -defmodule <%= inspect context.web_module %>.<%= inspect Module.concat(schema.web_namespace, schema.alias) %>ConfirmationInstructionsLive do +defmodule <%= inspect context.web_module %>.<%= inspect Module.concat(schema.web_namespace, schema.alias) %>Live.ConfirmationInstructions do use <%= inspect context.web_module %>, :live_view alias <%= inspect context.module %> diff --git a/priv/templates/phx.gen.auth/confirmation_instructions_live_test.exs b/priv/templates/phx.gen.auth/confirmation_instructions_live_test.exs index c1ac8b6544..d8d1d23763 100644 --- a/priv/templates/phx.gen.auth/confirmation_instructions_live_test.exs +++ b/priv/templates/phx.gen.auth/confirmation_instructions_live_test.exs @@ -1,4 +1,4 @@ -defmodule <%= inspect context.web_module %>.<%= inspect Module.concat(schema.web_namespace, schema.alias) %>ConfirmationInstructionsLiveTest do +defmodule <%= inspect context.web_module %>.<%= inspect Module.concat(schema.web_namespace, schema.alias) %>Live.ConfirmationInstructionsTest do use <%= inspect context.web_module %>.ConnCase<%= test_case_options %> import Phoenix.LiveViewTest diff --git a/priv/templates/phx.gen.auth/confirmation_live.ex b/priv/templates/phx.gen.auth/confirmation_live.ex index 0ef2b62253..76ea55a495 100644 --- a/priv/templates/phx.gen.auth/confirmation_live.ex +++ b/priv/templates/phx.gen.auth/confirmation_live.ex @@ -1,4 +1,4 @@ -defmodule <%= inspect context.web_module %>.<%= inspect Module.concat(schema.web_namespace, schema.alias) %>ConfirmationLive do +defmodule <%= inspect context.web_module %>.<%= inspect Module.concat(schema.web_namespace, schema.alias) %>Live.Confirmation do use <%= inspect context.web_module %>, :live_view alias <%= inspect context.module %> diff --git a/priv/templates/phx.gen.auth/confirmation_live_test.exs b/priv/templates/phx.gen.auth/confirmation_live_test.exs index fc31128821..0eac2e43c0 100644 --- a/priv/templates/phx.gen.auth/confirmation_live_test.exs +++ b/priv/templates/phx.gen.auth/confirmation_live_test.exs @@ -1,4 +1,4 @@ -defmodule <%= inspect context.web_module %>.<%= inspect Module.concat(schema.web_namespace, schema.alias) %>ConfirmationLiveTest do +defmodule <%= inspect context.web_module %>.<%= inspect Module.concat(schema.web_namespace, schema.alias) %>Live.ConfirmationTest do use <%= inspect context.web_module %>.ConnCase<%= test_case_options %> import Phoenix.LiveViewTest diff --git a/priv/templates/phx.gen.auth/forgot_password_live.ex b/priv/templates/phx.gen.auth/forgot_password_live.ex index fb5ba7aa5e..25a1fcf6ce 100644 --- a/priv/templates/phx.gen.auth/forgot_password_live.ex +++ b/priv/templates/phx.gen.auth/forgot_password_live.ex @@ -1,4 +1,4 @@ -defmodule <%= inspect context.web_module %>.<%= inspect Module.concat(schema.web_namespace, schema.alias) %>ForgotPasswordLive do +defmodule <%= inspect context.web_module %>.<%= inspect Module.concat(schema.web_namespace, schema.alias) %>Live.ForgotPassword do use <%= inspect context.web_module %>, :live_view alias <%= inspect context.module %> diff --git a/priv/templates/phx.gen.auth/forgot_password_live_test.exs b/priv/templates/phx.gen.auth/forgot_password_live_test.exs index 4ad1455f6a..cbd6bdc6d6 100644 --- a/priv/templates/phx.gen.auth/forgot_password_live_test.exs +++ b/priv/templates/phx.gen.auth/forgot_password_live_test.exs @@ -1,4 +1,4 @@ -defmodule <%= inspect context.web_module %>.<%= inspect Module.concat(schema.web_namespace, schema.alias) %>ForgotPasswordLiveTest do +defmodule <%= inspect context.web_module %>.<%= inspect Module.concat(schema.web_namespace, schema.alias) %>Live.ForgotPasswordTest do use <%= inspect context.web_module %>.ConnCase<%= test_case_options %> import Phoenix.LiveViewTest diff --git a/priv/templates/phx.gen.auth/login_live.ex b/priv/templates/phx.gen.auth/login_live.ex index dd9003c97b..e8e634d3b5 100644 --- a/priv/templates/phx.gen.auth/login_live.ex +++ b/priv/templates/phx.gen.auth/login_live.ex @@ -1,4 +1,4 @@ -defmodule <%= inspect context.web_module %>.<%= inspect Module.concat(schema.web_namespace, schema.alias) %>LoginLive do +defmodule <%= inspect context.web_module %>.<%= inspect Module.concat(schema.web_namespace, schema.alias) %>Live.Login do use <%= inspect context.web_module %>, :live_view def render(assigns) do diff --git a/priv/templates/phx.gen.auth/login_live_test.exs b/priv/templates/phx.gen.auth/login_live_test.exs index 6b9d14268b..5cd486e7ca 100644 --- a/priv/templates/phx.gen.auth/login_live_test.exs +++ b/priv/templates/phx.gen.auth/login_live_test.exs @@ -1,4 +1,4 @@ -defmodule <%= inspect context.web_module %>.<%= inspect Module.concat(schema.web_namespace, schema.alias) %>LoginLiveTest do +defmodule <%= inspect context.web_module %>.<%= inspect Module.concat(schema.web_namespace, schema.alias) %>Live.LoginTest do use <%= inspect context.web_module %>.ConnCase<%= test_case_options %> import Phoenix.LiveViewTest diff --git a/priv/templates/phx.gen.auth/registration_live.ex b/priv/templates/phx.gen.auth/registration_live.ex index 3f7f422fe7..14aad47e1a 100644 --- a/priv/templates/phx.gen.auth/registration_live.ex +++ b/priv/templates/phx.gen.auth/registration_live.ex @@ -1,4 +1,4 @@ -defmodule <%= inspect context.web_module %>.<%= inspect Module.concat(schema.web_namespace, schema.alias) %>RegistrationLive do +defmodule <%= inspect context.web_module %>.<%= inspect Module.concat(schema.web_namespace, schema.alias) %>Live.Registration do use <%= inspect context.web_module %>, :live_view alias <%= inspect context.module %> diff --git a/priv/templates/phx.gen.auth/registration_live_test.exs b/priv/templates/phx.gen.auth/registration_live_test.exs index 1d12468191..4eef6a2c79 100644 --- a/priv/templates/phx.gen.auth/registration_live_test.exs +++ b/priv/templates/phx.gen.auth/registration_live_test.exs @@ -1,4 +1,4 @@ -defmodule <%= inspect context.web_module %>.<%= inspect Module.concat(schema.web_namespace, schema.alias) %>RegistrationLiveTest do +defmodule <%= inspect context.web_module %>.<%= inspect Module.concat(schema.web_namespace, schema.alias) %>Live.RegistrationTest do use <%= inspect context.web_module %>.ConnCase<%= test_case_options %> import Phoenix.LiveViewTest diff --git a/priv/templates/phx.gen.auth/reset_password_live.ex b/priv/templates/phx.gen.auth/reset_password_live.ex index 32845c9ee2..7d7d5e2adc 100644 --- a/priv/templates/phx.gen.auth/reset_password_live.ex +++ b/priv/templates/phx.gen.auth/reset_password_live.ex @@ -1,4 +1,4 @@ -defmodule <%= inspect context.web_module %>.<%= inspect Module.concat(schema.web_namespace, schema.alias) %>ResetPasswordLive do +defmodule <%= inspect context.web_module %>.<%= inspect Module.concat(schema.web_namespace, schema.alias) %>Live.ResetPassword do use <%= inspect context.web_module %>, :live_view alias <%= inspect context.module %> diff --git a/priv/templates/phx.gen.auth/reset_password_live_test.exs b/priv/templates/phx.gen.auth/reset_password_live_test.exs index 4e4995dd35..a326335d6a 100644 --- a/priv/templates/phx.gen.auth/reset_password_live_test.exs +++ b/priv/templates/phx.gen.auth/reset_password_live_test.exs @@ -1,4 +1,4 @@ -defmodule <%= inspect context.web_module %>.<%= inspect Module.concat(schema.web_namespace, schema.alias) %>ResetPasswordLiveTest do +defmodule <%= inspect context.web_module %>.<%= inspect Module.concat(schema.web_namespace, schema.alias) %>Live.ResetPasswordTest do use <%= inspect context.web_module %>.ConnCase<%= test_case_options %> import Phoenix.LiveViewTest diff --git a/priv/templates/phx.gen.auth/routes.ex b/priv/templates/phx.gen.auth/routes.ex index 60ced33601..1ca4b97cff 100644 --- a/priv/templates/phx.gen.auth/routes.ex +++ b/priv/templates/phx.gen.auth/routes.ex @@ -6,10 +6,10 @@ live_session :redirect_if_<%= schema.singular %>_is_authenticated, on_mount: [{<%= inspect auth_module %>, :redirect_if_<%= schema.singular %>_is_authenticated}] do - live "/<%= schema.plural %>/register", <%= inspect schema.alias %>RegistrationLive, :new - live "/<%= schema.plural %>/log_in", <%= inspect schema.alias %>LoginLive, :new - live "/<%= schema.plural %>/reset_password", <%= inspect schema.alias %>ForgotPasswordLive, :new - live "/<%= schema.plural %>/reset_password/:token", <%= inspect schema.alias %>ResetPasswordLive, :edit + live "/<%= schema.plural %>/register", <%= inspect schema.alias %>Live.Registration, :new + live "/<%= schema.plural %>/log_in", <%= inspect schema.alias %>Live.Login, :new + live "/<%= schema.plural %>/reset_password", <%= inspect schema.alias %>Live.ForgotPassword, :new + live "/<%= schema.plural %>/reset_password/:token", <%= inspect schema.alias %>Live.ResetPassword, :edit end post "/<%= schema.plural %>/log_in", <%= inspect schema.alias %>SessionController, :create<% else %> @@ -29,8 +29,8 @@ live_session :require_authenticated_<%= schema.singular %>, on_mount: [{<%= inspect auth_module %>, :ensure_authenticated}] do - live "/<%= schema.plural %>/settings", <%= inspect schema.alias %>SettingsLive, :edit - live "/<%= schema.plural %>/settings/confirm_email/:token", <%= inspect schema.alias %>SettingsLive, :confirm_email + live "/<%= schema.plural %>/settings", <%= inspect schema.alias %>Live.Settings, :edit + live "/<%= schema.plural %>/settings/confirm_email/:token", <%= inspect schema.alias %>Live.Settings, :confirm_email end<% else %> get "/<%= schema.plural %>/settings", <%= inspect schema.alias %>SettingsController, :edit @@ -45,8 +45,8 @@ live_session :current_<%= schema.singular %>, on_mount: [{<%= inspect auth_module %>, :mount_current_<%= schema.singular %>}] do - live "/<%= schema.plural %>/confirm/:token", <%= inspect schema.alias %>ConfirmationLive, :edit - live "/<%= schema.plural %>/confirm", <%= inspect schema.alias %>ConfirmationInstructionsLive, :new + live "/<%= schema.plural %>/confirm/:token", <%= inspect schema.alias %>Live.Confirmation, :edit + live "/<%= schema.plural %>/confirm", <%= inspect schema.alias %>Live.ConfirmationInstructions, :new end<% else %> get "/<%= schema.plural %>/confirm", <%= inspect schema.alias %>ConfirmationController, :new post "/<%= schema.plural %>/confirm", <%= inspect schema.alias %>ConfirmationController, :create diff --git a/priv/templates/phx.gen.auth/settings_live.ex b/priv/templates/phx.gen.auth/settings_live.ex index b6958f43a7..b63b374d25 100644 --- a/priv/templates/phx.gen.auth/settings_live.ex +++ b/priv/templates/phx.gen.auth/settings_live.ex @@ -1,4 +1,4 @@ -defmodule <%= inspect context.web_module %>.<%= inspect Module.concat(schema.web_namespace, schema.alias) %>SettingsLive do +defmodule <%= inspect context.web_module %>.<%= inspect Module.concat(schema.web_namespace, schema.alias) %>Live.Settings do use <%= inspect context.web_module %>, :live_view alias <%= inspect context.module %> diff --git a/priv/templates/phx.gen.auth/settings_live_test.exs b/priv/templates/phx.gen.auth/settings_live_test.exs index e4a25d1f2f..ac6e2702e3 100644 --- a/priv/templates/phx.gen.auth/settings_live_test.exs +++ b/priv/templates/phx.gen.auth/settings_live_test.exs @@ -1,4 +1,4 @@ -defmodule <%= inspect context.web_module %>.<%= inspect Module.concat(schema.web_namespace, schema.alias) %>SettingsLiveTest do +defmodule <%= inspect context.web_module %>.<%= inspect Module.concat(schema.web_namespace, schema.alias) %>Live.SettingsTest do use <%= inspect context.web_module %>.ConnCase<%= test_case_options %> alias <%= inspect context.module %> diff --git a/test/mix/tasks/phx.gen.auth_test.exs b/test/mix/tasks/phx.gen.auth_test.exs index d0944d8f76..ab61dae4a5 100644 --- a/test/mix/tasks/phx.gen.auth_test.exs +++ b/test/mix/tasks/phx.gen.auth_test.exs @@ -249,20 +249,20 @@ defmodule Mix.Tasks.Phx.Gen.AuthTest do assert file =~ ~s|deliver(user.email, "Update email instructions",| end) - assert_file("lib/my_app_web/live/user_registration_live.ex") - assert_file("test/my_app_web/live/user_registration_live_test.exs") - assert_file("lib/my_app_web/live/user_login_live.ex") - assert_file("test/my_app_web/live/user_login_live_test.exs") - assert_file("lib/my_app_web/live/user_reset_password_live.ex") - assert_file("test/my_app_web/live/user_reset_password_live_test.exs") - assert_file("lib/my_app_web/live/user_forgot_password_live.ex") - assert_file("test/my_app_web/live/user_forgot_password_live_test.exs") - assert_file("lib/my_app_web/live/user_settings_live.ex") - assert_file("test/my_app_web/live/user_settings_live_test.exs") - assert_file("lib/my_app_web/live/user_confirmation_live.ex") - assert_file("test/my_app_web/live/user_confirmation_live_test.exs") - assert_file("lib/my_app_web/live/user_confirmation_instructions_live.ex") - assert_file("test/my_app_web/live/user_confirmation_instructions_live_test.exs") + assert_file("lib/my_app_web/live/user_live/registration.ex") + assert_file("test/my_app_web/live/user_live/registration_test.exs") + assert_file("lib/my_app_web/live/user_live/login.ex") + assert_file("test/my_app_web/live/user_live/login_test.exs") + assert_file("lib/my_app_web/live/user_live/reset_password.ex") + assert_file("test/my_app_web/live/user_live/reset_password_test.exs") + assert_file("lib/my_app_web/live/user_live/forgot_password.ex") + assert_file("test/my_app_web/live/user_live/forgot_password_test.exs") + assert_file("lib/my_app_web/live/user_live/settings.ex") + assert_file("test/my_app_web/live/user_live/settings_test.exs") + assert_file("lib/my_app_web/live/user_live/confirmation.ex") + assert_file("test/my_app_web/live/user_live/confirmation_test.exs") + assert_file("lib/my_app_web/live/user_live/confirmation_instructions.ex") + assert_file("test/my_app_web/live/user_live/confirmation_instructions_test.exs") assert_file("lib/my_app_web/user_auth.ex") assert_file("test/my_app_web/user_auth_test.exs") @@ -290,10 +290,10 @@ defmodule Mix.Tasks.Phx.Gen.AuthTest do live_session :redirect_if_user_is_authenticated, on_mount: [{MyAppWeb.UserAuth, :redirect_if_user_is_authenticated}] do - live "/users/register", UserRegistrationLive, :new - live "/users/log_in", UserLoginLive, :new - live "/users/reset_password", UserForgotPasswordLive, :new - live "/users/reset_password/:token", UserResetPasswordLive, :edit + live "/users/register", UserLive.Registration, :new + live "/users/log_in", UserLive.Login, :new + live "/users/reset_password", UserLive.ForgotPassword, :new + live "/users/reset_password/:token", UserLive.ResetPassword, :edit end post "/users/log_in", UserSessionController, :create @@ -304,8 +304,8 @@ defmodule Mix.Tasks.Phx.Gen.AuthTest do live_session :require_authenticated_user, on_mount: [{MyAppWeb.UserAuth, :ensure_authenticated}] do - live "/users/settings", UserSettingsLive, :edit - live "/users/settings/confirm_email/:token", UserSettingsLive, :confirm_email + live "/users/settings", UserLive.Settings, :edit + live "/users/settings/confirm_email/:token", UserLive.Settings, :confirm_email end end @@ -316,8 +316,8 @@ defmodule Mix.Tasks.Phx.Gen.AuthTest do live_session :current_user, on_mount: [{MyAppWeb.UserAuth, :mount_current_user}] do - live "/users/confirm/:token", UserConfirmationLive, :edit - live "/users/confirm", UserConfirmationInstructionsLive, :new + live "/users/confirm/:token", UserLive.Confirmation, :edit + live "/users/confirm", UserLive.ConfirmationInstructions, :new end end """ @@ -387,10 +387,10 @@ defmodule Mix.Tasks.Phx.Gen.AuthTest do live_session :redirect_if_user_is_authenticated, on_mount: [{MyAppWeb.UserAuth, :redirect_if_user_is_authenticated}] do - live "/users/register", UserRegistrationLive, :new - live "/users/log_in", UserLoginLive, :new - live "/users/reset_password", UserForgotPasswordLive, :new - live "/users/reset_password/:token", UserResetPasswordLive, :edit + live "/users/register", UserLive.Registration, :new + live "/users/log_in", UserLive.Login, :new + live "/users/reset_password", UserLive.ForgotPassword, :new + live "/users/reset_password/:token", UserLive.ResetPassword, :edit end post "/users/log_in", UserSessionController, :create @@ -401,8 +401,8 @@ defmodule Mix.Tasks.Phx.Gen.AuthTest do live_session :require_authenticated_user, on_mount: [{MyAppWeb.UserAuth, :ensure_authenticated}] do - live "/users/settings", UserSettingsLive, :edit - live "/users/settings/confirm_email/:token", UserSettingsLive, :confirm_email + live "/users/settings", UserLive.Settings, :edit + live "/users/settings/confirm_email/:token", UserLive.Settings, :confirm_email end end @@ -413,8 +413,8 @@ defmodule Mix.Tasks.Phx.Gen.AuthTest do live_session :current_user, on_mount: [{MyAppWeb.UserAuth, :mount_current_user}] do - live "/users/confirm/:token", UserConfirmationLive, :edit - live "/users/confirm", UserConfirmationInstructionsLive, :new + live "/users/confirm/:token", UserLive.Confirmation, :edit + live "/users/confirm", UserLive.ConfirmationInstructions, :new end end """