mirror of
https://github.com/philomena-dev/philomena.git
synced 2025-02-17 11:04:22 +01:00
fix error when changing name to existing one (fixes philomena-dev/philomena#45)
This commit is contained in:
parent
cc571a38c2
commit
f4b7cc5f5f
2 changed files with 5 additions and 5 deletions
|
@ -603,7 +603,7 @@ defmodule Philomena.Users do
|
||||||
|> Multi.update(:account, account)
|
|> Multi.update(:account, account)
|
||||||
|> Repo.transaction()
|
|> Repo.transaction()
|
||||||
|> case do
|
|> case do
|
||||||
{:ok, %{account: %{name: new_name}}} = result ->
|
{:ok, %{account: %{name: new_name}}} ->
|
||||||
spawn(fn ->
|
spawn(fn ->
|
||||||
Images.user_name_reindex(old_name, new_name)
|
Images.user_name_reindex(old_name, new_name)
|
||||||
Comments.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)
|
Reports.user_name_reindex(old_name, new_name)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
result
|
{:ok, account}
|
||||||
|
|
||||||
result ->
|
{:error, :account, changeset, _changes} ->
|
||||||
result
|
{:error, changeset}
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -19,7 +19,7 @@ defmodule PhilomenaWeb.Registration.NameController do
|
||||||
|> put_flash(:info, "Name successfully updated.")
|
|> put_flash(:info, "Name successfully updated.")
|
||||||
|> redirect(to: Routes.profile_path(conn, :show, user))
|
|> redirect(to: Routes.profile_path(conn, :show, user))
|
||||||
|
|
||||||
{:error, %{account: changeset}} ->
|
{:error, changeset} ->
|
||||||
render(conn, "edit.html", changeset: changeset)
|
render(conn, "edit.html", changeset: changeset)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue