diff --git a/core/lib/core_web/live/user/confirm_token.ex b/core/lib/core_web/live/user/confirm_token.ex
index d5b2d88b1..f0db5f464 100644
--- a/core/lib/core_web/live/user/confirm_token.ex
+++ b/core/lib/core_web/live/user/confirm_token.ex
@@ -11,26 +11,32 @@ defmodule CoreWeb.User.ConfirmToken do
alias Core.Accounts
alias Core.Accounts.User
+ require Logger
+
def mount(%{"token" => token}, _session, socket) do
require_feature(:password_sign_in)
- connected? = Phoenix.LiveView.connected?(socket)
-
- {:ok,
- socket
- |> assign(
- failed: false,
- token: token
- )
- |> confirm_user(connected?)}
+
+ {
+ :ok,
+ socket
+ |> assign(
+ failed: false,
+ token: token
+ )
+ |> update_confirm_button()
+ }
end
- defp confirm_user(socket, false) do
- # Only confirm user when socket is connected to prevent early invalidation of token.
- # https://github.com/eyra/mono/issues/615
- socket
+ defp update_confirm_button(socket) do
+ confirm_button = %{
+ action: %{type: :send, event: "confirm"},
+ face: %{type: :primary, label: dgettext("eyra-account", "confirm.button")}
+ }
+
+ assign(socket, confirm_button: confirm_button)
end
- defp confirm_user(%{assigns: %{token: token}} = socket, true) do
+ defp confirm_user(%{assigns: %{token: token}} = socket) do
case Accounts.confirm_user(token) do
{:ok, user} ->
handle_succeeded(socket, user)
@@ -41,12 +47,16 @@ defmodule CoreWeb.User.ConfirmToken do
end
defp handle_succeeded(socket, %{email: email}) do
+ Logger.notice("Confirm user: handle_succeeded #{email}")
+
socket
|> put_flash(:info, dgettext("eyra-user", "account.activated.successfully"))
|> redirect(to: ~p"/user/signin?email=#{email}")
end
defp handle_failed(socket) do
+ Logger.notice("Confirm user: handle_failed")
+
assign(socket,
failed: true,
status: :invalid,
@@ -58,6 +68,11 @@ defmodule CoreWeb.User.ConfirmToken do
{:noreply, socket}
end
+ @impl true
+ def handle_event("confirm", _, socket) do
+ {:noreply, confirm_user(socket)}
+ end
+
@impl true
def handle_event("resend-token", %{"user" => %{"email" => email}}, socket) do
case User.valid_email_changeset(email) do
@@ -112,6 +127,13 @@ defmodule CoreWeb.User.ConfirmToken do
<.email_input form={form} field={:email} label_text={dgettext("eyra-user", "confirm.token.email.label")} />
+ <% else %>
+ <%= dgettext("eyra-account", "activation.confirm.title") %>
+ <%= dgettext("eyra-account", "activation.confirm.body") %>
+ <.spacing value="M" />
+ <.wrap>
+
+
<% end %>
diff --git a/core/priv/gettext/en/LC_MESSAGES/eyra-account.po b/core/priv/gettext/en/LC_MESSAGES/eyra-account.po
index 7d9615801..1ed951b69 100644
--- a/core/priv/gettext/en/LC_MESSAGES/eyra-account.po
+++ b/core/priv/gettext/en/LC_MESSAGES/eyra-account.po
@@ -128,7 +128,7 @@ msgstr "Sign in"
#, elixir-autogen, elixir-format, fuzzy
msgid "await.confirmation.description"
-msgstr "Your account has been created. We send you an activation email. Please click the link in the email to activate your account."
+msgstr "Your account has been created. We have sent you an activation email. Please click the link in the email to activate your account."
#, elixir-autogen, elixir-format
msgid "activation.failed.body"
@@ -137,3 +137,15 @@ msgstr "Your account might already have been activated or the activation link is
#, elixir-autogen, elixir-format
msgid "activation.failed.title"
msgstr "Account activation"
+
+#, elixir-autogen, elixir-format, fuzzy
+msgid "activation.confirm.body"
+msgstr "Click the button below to activate your account. You will be forwarded to the sign in page."
+
+#, elixir-autogen, elixir-format, fuzzy
+msgid "activation.confirm.title"
+msgstr "Account activation"
+
+#, elixir-autogen, elixir-format
+msgid "confirm.button"
+msgstr "Activate"
diff --git a/core/priv/gettext/en/LC_MESSAGES/eyra-assignment.po b/core/priv/gettext/en/LC_MESSAGES/eyra-assignment.po
index 0bb885767..78c0996ad 100644
--- a/core/priv/gettext/en/LC_MESSAGES/eyra-assignment.po
+++ b/core/priv/gettext/en/LC_MESSAGES/eyra-assignment.po
@@ -309,6 +309,8 @@ msgstr "
Privacy statement URL
Use the URL below to refer to the uploade
#, elixir-autogen, elixir-format
msgid "privacy.title"
msgstr "Privacy"
+
+#, elixir-autogen, elixir-format
msgid "tabbar.item.monitor"
msgstr "Monitor"
@@ -336,10 +338,10 @@ msgstr "Declined consent"
msgid "settings.general.title"
msgstr "General"
-#, elixir-autogen, elixir-format, fuzzy
-msgid "settings.subject_count.label"
-msgstr "Expected number of participants"
-
#, elixir-autogen, elixir-format, fuzzy
msgid "settings.language.label"
msgstr "Language setting for participants"
+
+#, elixir-autogen, elixir-format, fuzzy
+msgid "settings.subject_count.label"
+msgstr "Expected number of participants"
diff --git a/core/priv/gettext/en/LC_MESSAGES/eyra-user.po b/core/priv/gettext/en/LC_MESSAGES/eyra-user.po
index 79b740502..72b321333 100644
--- a/core/priv/gettext/en/LC_MESSAGES/eyra-user.po
+++ b/core/priv/gettext/en/LC_MESSAGES/eyra-user.po
@@ -32,11 +32,11 @@ msgstr "Send instructions"
#, elixir-autogen, elixir-format
msgid "password_reset.reset_password_button"
-msgstr "Change password"
+msgstr "Create"
#, elixir-autogen, elixir-format
msgid "user.password_reset.title"
-msgstr "Change password"
+msgstr "New password"
#, elixir-autogen, elixir-format
msgid "Invalid email or password"
@@ -48,11 +48,11 @@ msgstr "Register"
#, elixir-autogen, elixir-format
msgid "reset.link"
-msgstr "Change password"
+msgstr "Forgot password?"
#, elixir-autogen, elixir-format, fuzzy
msgid "user.password_reset.flash"
-msgstr "Password change requested. If your email address is registered, you will receive instructions shortly."
+msgstr "New password requested. If your email address is registered, you will receive instructions shortly."
#, elixir-autogen, elixir-format, fuzzy
msgid "Invalid email"
@@ -60,7 +60,7 @@ msgstr "Invalid email address"
#, elixir-autogen, elixir-format, fuzzy
msgid "confirm.token.flash"
-msgstr "If your email address is registered, but not yet confirmed, you will receive email instructions shortly."
+msgstr "If your email address is registered, but not yet confirmed, you will receive instructions shortly."
#, elixir-autogen, elixir-format
msgid "Signed out successfully"
diff --git a/core/priv/gettext/eyra-account.pot b/core/priv/gettext/eyra-account.pot
index 59d96dce0..46c25fea0 100644
--- a/core/priv/gettext/eyra-account.pot
+++ b/core/priv/gettext/eyra-account.pot
@@ -137,3 +137,15 @@ msgstr ""
#, elixir-autogen, elixir-format
msgid "activation.failed.title"
msgstr ""
+
+#, elixir-autogen, elixir-format
+msgid "activation.confirm.body"
+msgstr ""
+
+#, elixir-autogen, elixir-format
+msgid "activation.confirm.title"
+msgstr ""
+
+#, elixir-autogen, elixir-format
+msgid "confirm.button"
+msgstr ""
diff --git a/core/priv/gettext/eyra-assignment.pot b/core/priv/gettext/eyra-assignment.pot
index 041494d68..a17ecc902 100644
--- a/core/priv/gettext/eyra-assignment.pot
+++ b/core/priv/gettext/eyra-assignment.pot
@@ -308,6 +308,9 @@ msgstr ""
#, elixir-autogen, elixir-format
msgid "privacy.title"
+msgstr ""
+
+#, elixir-autogen, elixir-format
msgid "tabbar.item.monitor"
msgstr ""
diff --git a/core/priv/gettext/nl/LC_MESSAGES/eyra-account.po b/core/priv/gettext/nl/LC_MESSAGES/eyra-account.po
index 4fd847414..07d3cef5c 100644
--- a/core/priv/gettext/nl/LC_MESSAGES/eyra-account.po
+++ b/core/priv/gettext/nl/LC_MESSAGES/eyra-account.po
@@ -137,3 +137,15 @@ msgstr "Jouw account activatie link is ongeldig of verlopen. Voer je e-mailadres
#, elixir-autogen, elixir-format
msgid "activation.failed.title"
msgstr "Activatie mislukt"
+
+#, elixir-autogen, elixir-format, fuzzy
+msgid "activation.confirm.body"
+msgstr "Klik op de knop hieronder om uw account te activeren. U wordt doorgestuurd naar het inlogscherm."
+
+#, elixir-autogen, elixir-format, fuzzy
+msgid "activation.confirm.title"
+msgstr "Account activatie"
+
+#, elixir-autogen, elixir-format
+msgid "confirm.button"
+msgstr "Activeer"
diff --git a/core/priv/gettext/nl/LC_MESSAGES/eyra-assignment.po b/core/priv/gettext/nl/LC_MESSAGES/eyra-assignment.po
index 4836c3163..eee9b1f28 100644
--- a/core/priv/gettext/nl/LC_MESSAGES/eyra-assignment.po
+++ b/core/priv/gettext/nl/LC_MESSAGES/eyra-assignment.po
@@ -310,6 +310,7 @@ msgstr "Privacyverklaring URL
Gebruik de URL hieronder om naar de geüp
msgid "privacy.title"
msgstr "Privacy"
+#, elixir-autogen, elixir-format
msgid "tabbar.item.monitor"
msgstr "Monitor"
@@ -337,10 +338,10 @@ msgstr "Toestemming geweigerd"
msgid "settings.general.title"
msgstr "General"
-#, elixir-autogen, elixir-format, fuzzy
-msgid "settings.subject_count.label"
-msgstr "Verwachtte aantal deelnemers"
-
#, elixir-autogen, elixir-format, fuzzy
msgid "settings.language.label"
msgstr ""
+
+#, elixir-autogen, elixir-format, fuzzy
+msgid "settings.subject_count.label"
+msgstr "Verwachtte aantal deelnemers"
diff --git a/core/systems/email/email/account_confirmation_instructions.html.eex b/core/systems/email/email/account_confirmation_instructions.html.eex
index 461ff2175..3be1a5bbd 100644
--- a/core/systems/email/email/account_confirmation_instructions.html.eex
+++ b/core/systems/email/email/account_confirmation_instructions.html.eex
@@ -2,7 +2,7 @@
Thank you for creating an account on Next. You are only one step removed from being able to use the platform.
-Click here to sign in. Your account will be activated and ready to use.
+Click here to activate your account.
If you did not register an account on Next, you can discard this email.
diff --git a/core/systems/email/email/account_confirmation_instructions.text.eex b/core/systems/email/email/account_confirmation_instructions.text.eex
index 12d91f1e5..6096b5885 100644
--- a/core/systems/email/email/account_confirmation_instructions.text.eex
+++ b/core/systems/email/email/account_confirmation_instructions.text.eex
@@ -2,7 +2,7 @@ Activate your account
Thank you for creating an account on Next. You are only one step removed from being able to use the platform.
-To sign in, click on this link <%= @url %>. Your account will be activated and ready to use.
+To activate your account, click on this link <%= @url %>.
If you did not register an account on Next, you can discard this email.
diff --git a/core/systems/email/email/reset_password_instructions.html.eex b/core/systems/email/email/reset_password_instructions.html.eex
index 1056b4f24..8ff1aa4f9 100644
--- a/core/systems/email/email/reset_password_instructions.html.eex
+++ b/core/systems/email/email/reset_password_instructions.html.eex
@@ -1,7 +1,7 @@
-Change password
+New password
-You have requested a password change on Next. Click here to create a new password.
-If you did not request a password change, you can discard this email.
+You have requested a new password for your Next account. Click here to create a new password.
+If you did not request a new password, you can discard this email.
Kind regards,
diff --git a/core/systems/email/email/reset_password_instructions.text.eex b/core/systems/email/email/reset_password_instructions.text.eex
index 2ed206c0d..eb752f787 100644
--- a/core/systems/email/email/reset_password_instructions.text.eex
+++ b/core/systems/email/email/reset_password_instructions.text.eex
@@ -1,7 +1,7 @@
-Password change
+New password
-You have requested a password change on Next. Click the following link to create a new password: <%= @url %>.
-If you did not request a password change, you can discard this email.
+You have requested a new password for your Next account. Click the following link to create a new password: <%= @url %>.
+If you did not request a new password, you can discard this email.
Kind regards,
diff --git a/core/test/core_web/live/user/confirm_token_test.exs b/core/test/core_web/live/user/confirm_token_test.exs
index 2d26d90ab..991e5154d 100644
--- a/core/test/core_web/live/user/confirm_token_test.exs
+++ b/core/test/core_web/live/user/confirm_token_test.exs
@@ -16,7 +16,12 @@ defmodule CoreWeb.Live.User.ConfirmToken.Test do
Accounts.deliver_user_confirmation_instructions(user, url)
end)
- {:error, {:redirect, %{to: to}}} = live(conn, Routes.live_path(conn, ConfirmToken, token))
+ {:ok, view, _html} = live(conn, Routes.live_path(conn, ConfirmToken, token))
+
+ {:error, {:redirect, %{to: to}}} =
+ view
+ |> element("[phx-click=\"confirm\"]")
+ |> render_click()
assert to == "/user/signin?#{URI.encode_query(%{email: user.email})}"
assert Accounts.get_user!(user.id).confirmed_at
@@ -30,22 +35,42 @@ defmodule CoreWeb.Live.User.ConfirmToken.Test do
Accounts.deliver_user_confirmation_instructions(user, url)
end)
- live(conn, Routes.live_path(conn, ConfirmToken, token))
+ {:ok, view, _html} = live(conn, Routes.live_path(conn, ConfirmToken, token))
+
+ {:error, {:redirect, %{to: _to}}} =
+ view
+ |> element("[phx-click=\"confirm\"]")
+ |> render_click()
+
# The second time should not redirect
- {:ok, _view, html} = live(conn, Routes.live_path(conn, ConfirmToken, "abc"))
+ {:ok, view, _html} = live(conn, Routes.live_path(conn, ConfirmToken, "abc"))
+
+ html =
+ view
+ |> element("[phx-click=\"confirm\"]")
+ |> render_click()
assert html =~ "Account activation"
end
test "an invalid token does not activate the account", %{conn: conn} do
user = Factories.insert!(:member, %{confirmed_at: nil})
- live(conn, Routes.live_path(conn, ConfirmToken, "abc"))
+ {:ok, view, _html} = live(conn, Routes.live_path(conn, ConfirmToken, "abc"))
+
+ view
+ |> element("[phx-click=\"confirm\"]")
+ |> render_click()
refute user.confirmed_at
end
test "an invalid token shows resend form", %{conn: conn} do
- {:ok, _view, html} = live(conn, Routes.live_path(conn, ConfirmToken, "abc"))
+ {:ok, view, _html} = live(conn, Routes.live_path(conn, ConfirmToken, "abc"))
+
+ html =
+ view
+ |> element("[phx-click=\"confirm\"]")
+ |> render_click()
assert html =~ "Account activation"
end
@@ -53,6 +78,10 @@ defmodule CoreWeb.Live.User.ConfirmToken.Test do
test "resend form validates the email field", %{conn: conn} do
{:ok, view, _html} = live(conn, Routes.live_path(conn, ConfirmToken, "test"))
+ view
+ |> element("[phx-click=\"confirm\"]")
+ |> render_click()
+
html =
view
|> element("form")
@@ -65,12 +94,16 @@ defmodule CoreWeb.Live.User.ConfirmToken.Test do
test "resend form fakes sending mail when user does not exist", %{conn: conn} do
{:ok, view, _html} = live(conn, Routes.live_path(conn, ConfirmToken, "test"))
+ view
+ |> element("[phx-click=\"confirm\"]")
+ |> render_click()
+
html =
view
|> element("form")
|> render_submit(%{user: %{email: Faker.Internet.email()}})
- assert html =~ "email instructions"
+ assert html =~ "receive instructions"
assert Repo.all(Accounts.UserToken) == []
end
@@ -78,12 +111,16 @@ defmodule CoreWeb.Live.User.ConfirmToken.Test do
user = Factories.insert!(:member, %{confirmed_at: nil})
{:ok, view, _html} = live(conn, Routes.live_path(conn, ConfirmToken, "test"))
+ view
+ |> element("[phx-click=\"confirm\"]")
+ |> render_click()
+
html =
view
|> element("form")
|> render_submit(%{user: %{email: user.email}})
- assert html =~ "email instructions"
+ assert html =~ "receive instructions"
assert Repo.get_by!(Accounts.UserToken, user_id: user.id).context == "confirm"
end
@@ -91,12 +128,16 @@ defmodule CoreWeb.Live.User.ConfirmToken.Test do
user = Factories.insert!(:member, %{confirmed_at: nil})
{:ok, view, _html} = live(conn, Routes.live_path(conn, ConfirmToken, "test"))
+ view
+ |> element("[phx-click=\"confirm\"]")
+ |> render_click()
+
html =
view
|> element("form")
|> render_submit(%{user: %{email: user.email}})
- assert html =~ "email instructions"
+ assert html =~ "receive instructions"
end
end