mirror of
https://github.com/plausible/analytics.git
synced 2024-12-25 10:33:01 +03:00
81c12884cd
* Add elixir action * Format the codebase * Add postgresql * Postgres config * Run postgres on localhost * Add clickhouse to CI
24 lines
445 B
Elixir
24 lines
445 B
Elixir
defmodule PlausibleWeb.RequireLoggedOutPlug do
|
|
import Plug.Conn
|
|
|
|
def init(options) do
|
|
options
|
|
end
|
|
|
|
def call(conn, _opts) do
|
|
cond do
|
|
conn.assigns[:current_user] ->
|
|
conn
|
|
|> put_resp_cookie("logged_in", "true",
|
|
http_only: false,
|
|
max_age: 60 * 60 * 24 * 365 * 5000
|
|
)
|
|
|> Phoenix.Controller.redirect(to: "/sites")
|
|
|> halt
|
|
|
|
:else ->
|
|
conn
|
|
end
|
|
end
|
|
end
|