From f4b7cc5f5f49d07a4daeab58d49d15627091f140 Mon Sep 17 00:00:00 2001 From: Luna D Date: Wed, 21 Oct 2020 20:39:16 +0200 Subject: [PATCH] fix error when changing name to existing one (fixes philomena-dev/philomena#45) --- lib/philomena/users.ex | 8 ++++---- .../controllers/registration/name_controller.ex | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/philomena/users.ex b/lib/philomena/users.ex index b02ed816..2e4704db 100644 --- a/lib/philomena/users.ex +++ b/lib/philomena/users.ex @@ -603,7 +603,7 @@ defmodule Philomena.Users do |> Multi.update(:account, account) |> Repo.transaction() |> case do - {:ok, %{account: %{name: new_name}}} = result -> + {:ok, %{account: %{name: new_name}}} -> spawn(fn -> Images.user_name_reindex(old_name, new_name) Comments.user_name_reindex(old_name, new_name) @@ -612,10 +612,10 @@ defmodule Philomena.Users do Reports.user_name_reindex(old_name, new_name) end) - result + {:ok, account} - result -> - result + {:error, :account, changeset, _changes} -> + {:error, changeset} end end diff --git a/lib/philomena_web/controllers/registration/name_controller.ex b/lib/philomena_web/controllers/registration/name_controller.ex index 4c089a72..3b71f483 100644 --- a/lib/philomena_web/controllers/registration/name_controller.ex +++ b/lib/philomena_web/controllers/registration/name_controller.ex @@ -19,7 +19,7 @@ defmodule PhilomenaWeb.Registration.NameController do |> put_flash(:info, "Name successfully updated.") |> redirect(to: Routes.profile_path(conn, :show, user)) - {:error, %{account: changeset}} -> + {:error, changeset} -> render(conn, "edit.html", changeset: changeset) end end