Clarify email registration handoff
Some checks are pending
Quality / full-local-gates (push) Waiting to run

This commit is contained in:
SimpleTest 2026-07-21 23:14:35 +03:00
parent 1d7e910bfd
commit b218bb9cee
4 changed files with 59 additions and 3 deletions

View File

@ -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

View File

@ -0,0 +1,37 @@
<.header>
{gettext("Check your email")}
<:subtitle>
{gettext("Your confirmation link is on its way.")}
</:subtitle>
</.header>
<div class="mx-auto mt-8 max-w-xl rounded-3xl border border-base-300 bg-base-100 p-6 shadow-sm sm:p-8">
<div class="flex gap-4">
<div class="grid size-11 shrink-0 place-items-center rounded-full bg-success/15 text-success">
<.icon name="hero-envelope" class="size-6" />
</div>
<div>
<h2 class="text-lg font-bold">{gettext("Open the newest Who Need Help email")}</h2>
<p class="mt-2 text-sm leading-6 text-base-content/70">
{gettext(
"Use the confirmation link in that email. You do not need to enter your address again on this site."
)}
</p>
</div>
</div>
<div class="mt-6 rounded-2xl bg-base-200 p-4 text-sm leading-6 text-base-content/70">
{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."
)}
</div>
<div class="mt-6 grid gap-3 sm:grid-cols-2">
<.link navigate={~p"/users/log-in"} class="btn btn-primary">
{gettext("Back to log in")}
</.link>
<.link navigate={~p"/users/register"} class="btn btn-outline">
{gettext("Use another email")}
</.link>
</div>
</div>

View File

@ -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

View File

@ -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."