defmodule WhoNeedHelpWeb.Router do use WhoNeedHelpWeb, :router import WhoNeedHelpWeb.UserAuth pipeline :browser do plug :accepts, ["html"] plug :fetch_session plug :fetch_live_flash plug :put_root_layout, html: {WhoNeedHelpWeb.Layouts, :root} plug :protect_from_forgery plug :put_secure_browser_headers plug :fetch_current_scope_for_user plug WhoNeedHelpWeb.Locale end pipeline :api do plug :accepts, ["json"] end pipeline :mobile do plug :accepts, ["json"] plug :fetch_session plug :protect_from_forgery plug :put_secure_browser_headers plug :fetch_current_scope_for_user end scope "/healthz", WhoNeedHelpWeb do pipe_through :api get "/live", HealthController, :live get "/ready", HealthController, :ready end scope "/mobile", WhoNeedHelpWeb do pipe_through :mobile post "/tracking/:assignment_id/position", MobileTrackingController, :update post "/tracking/:assignment_id/stop", MobileTrackingController, :stop end scope "/", WhoNeedHelpWeb do pipe_through :browser get "/", PageController, :home get "/feedback", FeedbackController, :show get "/safety", PageController, :safety end # Other scopes may use custom stacks. # scope "/api", WhoNeedHelpWeb do # pipe_through :api # end # Enable LiveDashboard and Swoosh mailbox preview in development if Application.compile_env(:who_need_help, :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 scope "/dev" do pipe_through :browser live_dashboard "/dashboard", metrics: WhoNeedHelpWeb.Telemetry forward "/mailbox", Plug.Swoosh.MailboxPreview end end ## Authentication routes scope "/", WhoNeedHelpWeb do pipe_through [:browser, :redirect_if_user_is_authenticated] get "/users/register", UserRegistrationController, :new post "/users/register", UserRegistrationController, :create end scope "/", WhoNeedHelpWeb do pipe_through [:browser, :require_authenticated_user] get "/users/settings", UserSettingsController, :edit put "/users/settings", UserSettingsController, :update get "/users/settings/confirm-email/:token", UserSettingsController, :confirm_email get "/auth/social/:provider", SocialOAuthController, :request get "/auth/social/:provider/callback", SocialOAuthController, :callback end scope "/", WhoNeedHelpWeb do pipe_through :browser live_session :authenticated, on_mount: [{WhoNeedHelpWeb.UserAuth, :ensure_authenticated}] do live "/requests", RequestLive.Index, :index live "/requests/new", RequestLive.New, :new live "/requests/:id", RequestLive.Show, :show live "/activities", ActivityLive.Index, :index live "/activities/new", ActivityLive.New, :new live "/activities/:id", ActivityLive.Show, :show live "/categories/proposals", CategoryProposalLive, :index live "/profile", ProfileLive, :edit live "/leaderboard", LeaderboardLive, :index end live_session :moderation, on_mount: [{WhoNeedHelpWeb.UserAuth, :ensure_moderator}] do live "/moderation", ModerationLive, :index end end scope "/", WhoNeedHelpWeb do pipe_through [:browser] get "/users/log-in", UserSessionController, :new get "/users/log-in/:token", UserSessionController, :confirm post "/users/log-in", UserSessionController, :create delete "/users/log-out", UserSessionController, :delete end end