remove unnecessary referrer redirects

This commit is contained in:
byte[] 2020-09-07 00:28:24 -04:00
parent 04b893eaaf
commit a2e524b535
10 changed files with 14 additions and 20 deletions

View file

@ -21,7 +21,7 @@ defmodule PhilomenaWeb.Admin.DnpEntry.TransitionController do
{:error, _changeset} -> {:error, _changeset} ->
conn conn
|> put_flash(:error, "Failed to update DNP entry!") |> 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
end end

View file

@ -37,7 +37,7 @@ defmodule PhilomenaWeb.Conversation.MessageController do
_error -> _error ->
conn conn
|> put_flash(:error, "There was an error posting your message") |> 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 end
end end

View file

@ -20,7 +20,7 @@ defmodule PhilomenaWeb.DuplicateReport.ClaimController do
conn conn
|> put_flash(:info, "Successfully claimed report.") |> put_flash(:info, "Successfully claimed report.")
|> redirect(external: conn.assigns.referrer) |> redirect(to: Routes.duplicate_report_path(conn, :index))
end end
def delete(conn, _params) do def delete(conn, _params) do
@ -28,6 +28,6 @@ defmodule PhilomenaWeb.DuplicateReport.ClaimController do
conn conn
|> put_flash(:info, "Successfully released report.") |> put_flash(:info, "Successfully released report.")
|> redirect(external: conn.assigns.referrer) |> redirect(to: Routes.duplicate_report_path(conn, :index))
end end
end end

View file

@ -21,6 +21,6 @@ defmodule PhilomenaWeb.DuplicateReport.RejectController do
conn conn
|> put_flash(:info, "Successfully rejected report.") |> put_flash(:info, "Successfully rejected report.")
|> redirect(external: conn.assigns.referrer) |> redirect(to: Routes.duplicate_report_path(conn, :index))
end end
end end

View file

@ -56,7 +56,7 @@ defmodule PhilomenaWeb.DuplicateReportController do
{:error, _changeset} -> {:error, _changeset} ->
conn conn
|> put_flash(:error, "Failed to submit duplicate report") |> put_flash(:error, "Failed to submit duplicate report")
|> redirect(external: conn.assigns.referrer) |> redirect(to: Routes.image_path(conn, :show, source))
end end
end end

View file

@ -6,16 +6,10 @@ defmodule PhilomenaWeb.Filter.SpoilerTypeController do
plug PhilomenaWeb.RequireUserPlug plug PhilomenaWeb.RequireUserPlug
def update(conn, %{"user" => user_params}) do def update(conn, %{"user" => user_params}) do
case Users.update_spoiler_type(conn.assigns.current_user, user_params) do {:ok, user} = Users.update_spoiler_type(conn.assigns.current_user, user_params)
{:ok, user} ->
conn
|> put_flash(:info, "Changed spoiler type to #{user.spoiler_type}")
|> redirect(external: conn.assigns.referrer)
{:error, _changeset} -> conn
conn |> put_flash(:info, "Changed spoiler type to #{user.spoiler_type}")
|> put_flash(:error, "Failed to set spoiler type") |> redirect(external: conn.assigns.referrer)
|> redirect(external: conn.assigns.referrer)
end
end end
end end

View file

@ -18,7 +18,7 @@ defmodule PhilomenaWeb.Image.RandomController do
if random_id do if random_id do
redirect(conn, to: Routes.image_path(conn, :show, random_id, scope)) redirect(conn, to: Routes.image_path(conn, :show, random_id, scope))
else else
redirect(conn, external: conn.assigns.referrer) redirect(conn, to: Routes.image_path(conn, :index))
end end
end end

View file

@ -62,7 +62,7 @@ defmodule PhilomenaWeb.Topic.PostController do
_error -> _error ->
conn conn
|> put_flash(:error, "There was an error creating the post") |> 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
end end

View file

@ -10,7 +10,7 @@ defmodule PhilomenaWeb.NotAuthorizedPlug do
conn conn
|> Controller.fetch_flash() |> Controller.fetch_flash()
|> Controller.put_flash(:error, "You can't access that page.") |> Controller.put_flash(:error, "You can't access that page.")
|> Controller.redirect(external: conn.assigns.referrer) |> Controller.redirect(to: "/")
|> Conn.halt() |> Conn.halt()
end end
end end

View file

@ -10,7 +10,7 @@ defmodule PhilomenaWeb.NotFoundPlug do
conn conn
|> Controller.fetch_flash() |> Controller.fetch_flash()
|> Controller.put_flash(:error, "Couldn't find what you were looking for!") |> Controller.put_flash(:error, "Couldn't find what you were looking for!")
|> Controller.redirect(external: conn.assigns.referrer) |> Controller.redirect(to: "/")
|> Conn.halt() |> Conn.halt()
end end
end end