analytics/lib/plausible_web/controllers/page_controller.ex
ruslandoga 0b7870dc4d
improve first launch experience for self-hosters (#2357)
* first launch

* dynamic children, wait for repo

* remove wait_for_repo and app env manipulations

* don't mention free trial in self-hosted pages

* add changelog

* assigns[:is_selfhost] -> @is_selfhost

* better changelog wording

* rm admin_user, admin_email, admin_pwd from app env

* rm DISABLE_AUTH

* redirect / to /login when not authenticated

* remove TODO

* Update lib/plausible_web/controllers/page_controller.ex

Co-authored-by: Uku Taht <Uku.taht@gmail.com>

* format

Co-authored-by: Uku Taht <Uku.taht@gmail.com>
2022-11-10 12:42:22 +01:00

16 lines
615 B
Elixir

defmodule PlausibleWeb.PageController do
use PlausibleWeb, :controller
use Plausible.Repo
@doc """
The root path is never accessible in Plausible.Cloud because it is handled by the upstream reverse proxy.
This controller action is only ever triggered in self-hosted Plausible. It redirects the user to /login where `PlausibleWeb.RequireLoggedOutPlug` plug kicks in. If they are already logged in, they are redirected to /sites, otherwise they'll see the /login page.
"""
def index(conn, _params) do
conn
|> put_session(:login_dest, conn.request_path)
|> redirect(to: "/login")
end
end