diff --git a/lib/towerops_web/router.ex b/lib/towerops_web/router.ex index f4ea120a..5b6719b7 100644 --- a/lib/towerops_web/router.ex +++ b/lib/towerops_web/router.ex @@ -1,6 +1,7 @@ defmodule ToweropsWeb.Router do use ToweropsWeb, :router + import Phoenix.LiveDashboard.Router import ToweropsWeb.UserAuth pipeline :browser do @@ -28,19 +29,18 @@ defmodule ToweropsWeb.Router do # pipe_through :api # end - # Enable LiveDashboard and Swoosh mailbox preview in development - if Application.compile_env(:towerops, :dev_routes) do - # If you want to use the LiveDashboard in production, you should put - # it behind authentication and allow only admins to access it. - # If your application does not have an admins-only section yet, - # you can use Plug.BasicAuth to set up some basic authentication - # as long as you are also using SSL (which you should anyway). - import Phoenix.LiveDashboard.Router + # Enable LiveDashboard in production with authentication + scope "/dashboard" do + pipe_through [:browser, :require_authenticated_user] + live_dashboard "/", metrics: ToweropsWeb.Telemetry + end + + # Enable Swoosh mailbox preview in development + if Application.compile_env(:towerops, :dev_routes) do scope "/dev" do pipe_through :browser - live_dashboard "/dashboard", metrics: ToweropsWeb.Telemetry forward "/mailbox", Plug.Swoosh.MailboxPreview end end