mirror of
https://github.com/plausible/analytics.git
synced 2024-12-26 11:02:52 +03:00
19 lines
371 B
Elixir
19 lines
371 B
Elixir
defmodule PlausibleWeb.RequireAccountPlug do
|
|
import Plug.Conn
|
|
|
|
def init(options) do
|
|
options
|
|
end
|
|
|
|
def call(conn, _opts) do
|
|
case conn.assigns[:current_user] do
|
|
nil ->
|
|
Plug.Conn.put_session(conn, :login_dest, conn.request_path)
|
|
|> Phoenix.Controller.redirect(to: "/login")
|
|
|> halt
|
|
_email ->
|
|
conn
|
|
end
|
|
end
|
|
end
|