Files
Claper/lib/claper_web/notifiers/user_notifier.ex
Raúl R Pearson 03feb9a901 Fix email change confirmation (#172)
* Update translation files

I run `mix gettext.extract` and `mix gettext.merge priv/gettext`
as it seems that the files were somewhat outdated.

* Fix email change confirmation

Send the confirmation email to the new address

* Tweak email change confirmation email

* Run ./dev.sh format
2025-09-10 08:16:55 +02:00

60 lines
1.8 KiB
Elixir

defmodule ClaperWeb.Notifiers.UserNotifier do
use Phoenix.Swoosh, view: ClaperWeb.UserNotifierView, layout: {ClaperWeb.LayoutView, :email}
use Gettext, backend: ClaperWeb.Gettext
def magic(email, url) do
new()
|> to(email)
|> from(
{Application.get_env(:claper, :mail) |> Keyword.get(:from_name),
Application.get_env(:claper, :mail) |> Keyword.get(:from)}
)
|> subject(gettext("Connect to Claper"))
|> render_body("magic.html", %{url: url})
end
def welcome(email) do
new()
|> to(email)
|> from(
{Application.get_env(:claper, :mail) |> Keyword.get(:from_name),
Application.get_env(:claper, :mail) |> Keyword.get(:from)}
)
|> subject(gettext("Next steps to boost your presentations"))
|> render_body("welcome.html", %{email: email})
end
def update_email(new_email, url) do
new()
|> to(new_email)
|> from(
{Application.get_env(:claper, :mail) |> Keyword.get(:from_name),
Application.get_env(:claper, :mail) |> Keyword.get(:from)}
)
|> subject(gettext("Update email instructions"))
|> render_body("change.html", %{url: url})
end
def confirm(user, url) do
new()
|> to(user.email)
|> from(
{Application.get_env(:claper, :mail) |> Keyword.get(:from_name),
Application.get_env(:claper, :mail) |> Keyword.get(:from)}
)
|> subject(gettext("Confirmation instructions"))
|> render_body("confirm.html", %{user: user, url: url})
end
def reset(user, url) do
new()
|> to(user.email)
|> from(
{Application.get_env(:claper, :mail) |> Keyword.get(:from_name),
Application.get_env(:claper, :mail) |> Keyword.get(:from)}
)
|> subject(gettext("Reset password instructions"))
|> render_body("reset.html", %{user: user, url: url})
end
end