diff --git a/lib/philomena_web/controllers/admin/dnp_entry/transition_controller.ex b/lib/philomena_web/controllers/admin/dnp_entry/transition_controller.ex index 369e0469..a774ece0 100644 --- a/lib/philomena_web/controllers/admin/dnp_entry/transition_controller.ex +++ b/lib/philomena_web/controllers/admin/dnp_entry/transition_controller.ex @@ -21,7 +21,7 @@ defmodule PhilomenaWeb.Admin.DnpEntry.TransitionController do {:error, _changeset} -> conn |> put_flash(:error, "Failed to update DNP entry!") - |> redirect(external: conn.assigns.referrer) + |> redirect(to: Routes.dnp_entry_path(conn, :show, conn.assigns.dnp_entry)) end end diff --git a/lib/philomena_web/controllers/conversation/message_controller.ex b/lib/philomena_web/controllers/conversation/message_controller.ex index 6327877a..892091e6 100644 --- a/lib/philomena_web/controllers/conversation/message_controller.ex +++ b/lib/philomena_web/controllers/conversation/message_controller.ex @@ -37,7 +37,7 @@ defmodule PhilomenaWeb.Conversation.MessageController do _error -> conn |> put_flash(:error, "There was an error posting your message") - |> redirect(external: conn.assigns.referrer) + |> redirect(to: Routes.conversation_path(conn, :show, conversation)) end end end diff --git a/lib/philomena_web/controllers/duplicate_report/claim_controller.ex b/lib/philomena_web/controllers/duplicate_report/claim_controller.ex index 539282c8..e7a0e637 100644 --- a/lib/philomena_web/controllers/duplicate_report/claim_controller.ex +++ b/lib/philomena_web/controllers/duplicate_report/claim_controller.ex @@ -20,7 +20,7 @@ defmodule PhilomenaWeb.DuplicateReport.ClaimController do conn |> put_flash(:info, "Successfully claimed report.") - |> redirect(external: conn.assigns.referrer) + |> redirect(to: Routes.duplicate_report_path(conn, :index)) end def delete(conn, _params) do @@ -28,6 +28,6 @@ defmodule PhilomenaWeb.DuplicateReport.ClaimController do conn |> put_flash(:info, "Successfully released report.") - |> redirect(external: conn.assigns.referrer) + |> redirect(to: Routes.duplicate_report_path(conn, :index)) end end diff --git a/lib/philomena_web/controllers/duplicate_report/reject_controller.ex b/lib/philomena_web/controllers/duplicate_report/reject_controller.ex index 41ab6dab..577e343b 100644 --- a/lib/philomena_web/controllers/duplicate_report/reject_controller.ex +++ b/lib/philomena_web/controllers/duplicate_report/reject_controller.ex @@ -21,6 +21,6 @@ defmodule PhilomenaWeb.DuplicateReport.RejectController do conn |> put_flash(:info, "Successfully rejected report.") - |> redirect(external: conn.assigns.referrer) + |> redirect(to: Routes.duplicate_report_path(conn, :index)) end end diff --git a/lib/philomena_web/controllers/duplicate_report_controller.ex b/lib/philomena_web/controllers/duplicate_report_controller.ex index 59e3072d..f72a7d0b 100644 --- a/lib/philomena_web/controllers/duplicate_report_controller.ex +++ b/lib/philomena_web/controllers/duplicate_report_controller.ex @@ -56,7 +56,7 @@ defmodule PhilomenaWeb.DuplicateReportController do {:error, _changeset} -> conn |> put_flash(:error, "Failed to submit duplicate report") - |> redirect(external: conn.assigns.referrer) + |> redirect(to: Routes.image_path(conn, :show, source)) end end diff --git a/lib/philomena_web/controllers/filter/spoiler_type_controller.ex b/lib/philomena_web/controllers/filter/spoiler_type_controller.ex index f0527068..c92aed85 100644 --- a/lib/philomena_web/controllers/filter/spoiler_type_controller.ex +++ b/lib/philomena_web/controllers/filter/spoiler_type_controller.ex @@ -6,16 +6,10 @@ defmodule PhilomenaWeb.Filter.SpoilerTypeController do plug PhilomenaWeb.RequireUserPlug def update(conn, %{"user" => user_params}) do - case Users.update_spoiler_type(conn.assigns.current_user, user_params) do - {:ok, user} -> - conn - |> put_flash(:info, "Changed spoiler type to #{user.spoiler_type}") - |> redirect(external: conn.assigns.referrer) + {:ok, user} = Users.update_spoiler_type(conn.assigns.current_user, user_params) - {:error, _changeset} -> - conn - |> put_flash(:error, "Failed to set spoiler type") - |> redirect(external: conn.assigns.referrer) - end + conn + |> put_flash(:info, "Changed spoiler type to #{user.spoiler_type}") + |> redirect(external: conn.assigns.referrer) end end diff --git a/lib/philomena_web/controllers/image/random_controller.ex b/lib/philomena_web/controllers/image/random_controller.ex index d0e22292..60611c79 100644 --- a/lib/philomena_web/controllers/image/random_controller.ex +++ b/lib/philomena_web/controllers/image/random_controller.ex @@ -18,7 +18,7 @@ defmodule PhilomenaWeb.Image.RandomController do if random_id do redirect(conn, to: Routes.image_path(conn, :show, random_id, scope)) else - redirect(conn, external: conn.assigns.referrer) + redirect(conn, to: Routes.image_path(conn, :index)) end end diff --git a/lib/philomena_web/controllers/topic/post_controller.ex b/lib/philomena_web/controllers/topic/post_controller.ex index 296d580a..1606b61c 100644 --- a/lib/philomena_web/controllers/topic/post_controller.ex +++ b/lib/philomena_web/controllers/topic/post_controller.ex @@ -62,7 +62,7 @@ defmodule PhilomenaWeb.Topic.PostController do _error -> conn |> put_flash(:error, "There was an error creating the post") - |> redirect(external: conn.assigns.referrer) + |> redirect(to: Routes.forum_topic_path(conn, :show, forum, topic)) end end diff --git a/lib/philomena_web/plugs/not_authorized_plug.ex b/lib/philomena_web/plugs/not_authorized_plug.ex index 382551bb..220edd7c 100644 --- a/lib/philomena_web/plugs/not_authorized_plug.ex +++ b/lib/philomena_web/plugs/not_authorized_plug.ex @@ -10,7 +10,7 @@ defmodule PhilomenaWeb.NotAuthorizedPlug do conn |> Controller.fetch_flash() |> Controller.put_flash(:error, "You can't access that page.") - |> Controller.redirect(external: conn.assigns.referrer) + |> Controller.redirect(to: "/") |> Conn.halt() end end diff --git a/lib/philomena_web/plugs/not_found_plug.ex b/lib/philomena_web/plugs/not_found_plug.ex index 8f169d0c..3185218b 100644 --- a/lib/philomena_web/plugs/not_found_plug.ex +++ b/lib/philomena_web/plugs/not_found_plug.ex @@ -10,7 +10,7 @@ defmodule PhilomenaWeb.NotFoundPlug do conn |> Controller.fetch_flash() |> Controller.put_flash(:error, "Couldn't find what you were looking for!") - |> Controller.redirect(external: conn.assigns.referrer) + |> Controller.redirect(to: "/") |> Conn.halt() end end