philomena/lib/philomena_web/plugs/not_authorized_plug.ex
2019-12-04 07:38:57 -05:00

14 lines
No EOL
343 B
Elixir

defmodule PhilomenaWeb.NotAuthorizedPlug do
alias Phoenix.Controller
alias Plug.Conn
def init([]), do: []
def call(conn), do: call(conn, nil)
def call(conn, _opts) do
conn
|> Controller.put_flash(:error, "You can't access that page.")
|> Controller.redirect(external: conn.assigns.referrer)
|> Conn.halt()
end
end