From b218bb9cee1c99acea073b5f257a22f561cdddbb Mon Sep 17 00:00:00 2001 From: SimpleTest Date: Tue, 21 Jul 2026 23:14:35 +0300 Subject: [PATCH] Clarify email registration handoff --- .../user_registration_controller.ex | 6 ++- .../user_registration_html/sent.html.heex | 37 +++++++++++++++++++ lib/who_need_help_web/router.ex | 1 + .../user_registration_controller_test.exs | 18 ++++++++- 4 files changed, 59 insertions(+), 3 deletions(-) create mode 100644 lib/who_need_help_web/controllers/user_registration_html/sent.html.heex diff --git a/lib/who_need_help_web/controllers/user_registration_controller.ex b/lib/who_need_help_web/controllers/user_registration_controller.ex index c57ab6a..6a415cc 100644 --- a/lib/who_need_help_web/controllers/user_registration_controller.ex +++ b/lib/who_need_help_web/controllers/user_registration_controller.ex @@ -14,6 +14,10 @@ defmodule WhoNeedHelpWeb.UserRegistrationController do render_registration(conn, changeset) end + def sent(conn, _params) do + render(conn, :sent) + end + def create(conn, %{"user" => user_params}) when is_map(user_params) do user_params = normalize_registration_params(user_params) email_scope = normalize_email_scope(user_params["email"]) @@ -108,7 +112,7 @@ defmodule WhoNeedHelpWeb.UserRegistrationController do "If this address can be registered or signed in, login instructions will arrive shortly." ) ) - |> redirect(to: ~p"/users/log-in") + |> redirect(to: ~p"/users/check-email") end defp unique_email_error?(%Ecto.Changeset{} = changeset) do diff --git a/lib/who_need_help_web/controllers/user_registration_html/sent.html.heex b/lib/who_need_help_web/controllers/user_registration_html/sent.html.heex new file mode 100644 index 0000000..bd4fed8 --- /dev/null +++ b/lib/who_need_help_web/controllers/user_registration_html/sent.html.heex @@ -0,0 +1,37 @@ +<.header> + {gettext("Check your email")} + <:subtitle> + {gettext("Your confirmation link is on its way.")} + + + +
+
+
+ <.icon name="hero-envelope" class="size-6" /> +
+
+

{gettext("Open the newest Who Need Help email")}

+

+ {gettext( + "Use the confirmation link in that email. You do not need to enter your address again on this site." + )} +

+
+
+ +
+ {gettext( + "If the message is not in your inbox after a minute, check Spam. Older confirmation links may have been replaced by the newest one." + )} +
+ +
+ <.link navigate={~p"/users/log-in"} class="btn btn-primary"> + {gettext("Back to log in")} + + <.link navigate={~p"/users/register"} class="btn btn-outline"> + {gettext("Use another email")} + +
+
diff --git a/lib/who_need_help_web/router.ex b/lib/who_need_help_web/router.ex index 41688b7..2f119fd 100644 --- a/lib/who_need_help_web/router.ex +++ b/lib/who_need_help_web/router.ex @@ -118,6 +118,7 @@ defmodule WhoNeedHelpWeb.Router do get "/users/register", UserRegistrationController, :new post "/users/register", UserRegistrationController, :create + get "/users/check-email", UserRegistrationController, :sent post "/auth/google/login", GoogleAuthController, :start_login post "/auth/google/register", GoogleAuthController, :start_registration get "/auth/google/complete", GoogleAuthController, :complete diff --git a/test/who_need_help_web/controllers/user_registration_controller_test.exs b/test/who_need_help_web/controllers/user_registration_controller_test.exs index 9f7719a..3365dac 100644 --- a/test/who_need_help_web/controllers/user_registration_controller_test.exs +++ b/test/who_need_help_web/controllers/user_registration_controller_test.exs @@ -28,6 +28,20 @@ defmodule WhoNeedHelpWeb.UserRegistrationControllerTest do end end + describe "GET /users/check-email" do + test "explains that the confirmation continues from the email", %{conn: conn} do + conn = get(conn, ~p"/users/check-email") + response = html_response(conn, 200) + + assert get_resp_header(conn, "cache-control") == ["no-store"] + assert response =~ "Check your email" + assert response =~ "You do not need to enter your address again" + assert response =~ "check Spam" + assert response =~ ~p"/users/log-in" + assert response =~ ~p"/users/register" + end + end + describe "POST /users/register" do test "returns bad request for malformed parameters", %{conn: conn} do conn = post(conn, ~p"/users/register", %{"user" => "invalid"}) @@ -61,7 +75,7 @@ defmodule WhoNeedHelpWeb.UserRegistrationControllerTest do }) refute get_session(conn, :user_token) - assert redirected_to(conn) == ~p"/users/log-in" + assert redirected_to(conn) == ~p"/users/check-email" assert conn.assigns.flash["info"] =~ "If this address can be registered or signed in, login instructions will arrive shortly." @@ -75,7 +89,7 @@ defmodule WhoNeedHelpWeb.UserRegistrationControllerTest do existing_conn = post(conn, ~p"/users/register", params) - assert redirected_to(existing_conn) == ~p"/users/log-in" + assert redirected_to(existing_conn) == ~p"/users/check-email" assert existing_conn.assigns.flash["info"] == "If this address can be registered or signed in, login instructions will arrive shortly."