analytics/lib/plausible_web/plugs/require_logged_out.ex
2019-09-02 12:29:19 +01:00

17 lines
298 B
Elixir

defmodule PlausibleWeb.RequireLoggedOutPlug do
def init(options) do
options
end
def call(conn, _opts) do
cond do
conn.assigns[:current_user] ->
conn
|> Phoenix.Controller.redirect(to: "/")
|> Plug.Conn.halt
:else ->
conn
end
end
end