analytics/lib/plausible_web/plugs/require_logged_out.ex

17 lines
298 B
Elixir
Raw Normal View History

2019-09-02 14:29:19 +03:00
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