fix error when changing name to existing one (fixes philomena-dev/philomena#45)

This commit is contained in:
Luna D 2020-10-21 20:39:16 +02:00
parent cc571a38c2
commit f4b7cc5f5f
No known key found for this signature in database
GPG key ID: 81AF416F2CC36FC8
2 changed files with 5 additions and 5 deletions

View file

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

View file

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