diff --git a/lib/philomena_web/plugs/filter_banned_users_plug.ex b/lib/philomena_web/plugs/filter_banned_users_plug.ex index 37cb1612..989edb71 100644 --- a/lib/philomena_web/plugs/filter_banned_users_plug.ex +++ b/lib/philomena_web/plugs/filter_banned_users_plug.ex @@ -21,13 +21,27 @@ defmodule PhilomenaWeb.FilterBannedUsersPlug do conn.assigns.current_ban |> maybe_halt(conn, redirect_url) + |> maybe_halt_no_fingerprint() end - def maybe_halt(nil, conn, _redirect_url), do: conn - def maybe_halt(_current_ban, conn, redirect_url) do + defp maybe_halt(nil, conn, _redirect_url), do: conn + defp maybe_halt(_current_ban, conn, redirect_url) do conn |> Controller.put_flash(:error, "You are currently banned.") |> Controller.redirect(external: redirect_url) |> Conn.halt() end -end \ No newline at end of file + + defp maybe_halt_no_fingerprint(%{halted: true} = conn), do: conn + defp maybe_halt_no_fingerprint(conn) do + conn = Conn.fetch_cookies(conn) + + case conn.cookies["_ses"] do + nil -> + PhilomenaWeb.NotAuthorizedPlug.call(conn) + + _other -> + conn + end + end +end