diff --git a/lib/atomic/accounts/user_notifier.ex b/lib/atomic/accounts/user_notifier.ex index b539f01c0..30aa3a487 100644 --- a/lib/atomic/accounts/user_notifier.ex +++ b/lib/atomic/accounts/user_notifier.ex @@ -12,8 +12,17 @@ defmodule Atomic.Accounts.UserNotifier do |> to(email) end - defp deliver(a, b, c) do - {:ok, ""} + defp deliver(recipient, subject, body) do + email = + new() + |> to(recipient) + |> from({"Atomic", "contact@example.com"}) + |> subject(subject) + |> text_body(body) + + with {:ok, _metadata} <- Mailer.deliver(email) do + {:ok, email} + end end @doc """ @@ -40,12 +49,17 @@ defmodule Atomic.Accounts.UserNotifier do Deliver instructions to reset a user password. """ def deliver_reset_password_instructions(user, url) do - base_email(to: user.email) - |> subject("Reset Password Instructions") - |> assign(:user, user) - |> assign(:url, url) - |> render_body("user_reset_password.txt") - |> Mailer.deliver() + email = + base_email(to: user.email) + |> subject("Reset Password Instructions") + |> assign(:user, user) + |> assign(:url, url) + |> render_body("user_reset_password.txt") + + case Mailer.deliver(email) do + {:ok, _term} -> {:ok, email} + {:error, ch} -> {:error, ch} + end end @doc """ diff --git a/lib/atomic_web/controllers/user_reset_password_controller.ex b/lib/atomic_web/controllers/user_reset_password_controller.ex index d6061f781..815459cf0 100644 --- a/lib/atomic_web/controllers/user_reset_password_controller.ex +++ b/lib/atomic_web/controllers/user_reset_password_controller.ex @@ -42,7 +42,7 @@ defmodule AtomicWeb.UserResetPasswordController do |> redirect(to: Routes.user_session_path(conn, :new)) {:error, changeset} -> - render(conn, "edit.html", changeset: changeset) + render(conn, "edit.html", changeset: changeset, error_message: nil) end end diff --git a/test/atomic_web/controllers/user_reset_password_controller_test.exs b/test/atomic_web/controllers/user_reset_password_controller_test.exs index 1ba6efea8..ff0a0a730 100644 --- a/test/atomic_web/controllers/user_reset_password_controller_test.exs +++ b/test/atomic_web/controllers/user_reset_password_controller_test.exs @@ -13,7 +13,7 @@ defmodule AtomicWeb.UserResetPasswordControllerTest do test "renders the reset password page", %{conn: conn} do conn = get(conn, Routes.user_reset_password_path(conn, :new)) response = html_response(conn, 200) - assert response =~ "