My space on the web
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

99 lines
2.9 KiB

defmodule MirageWeb.Router do
use MirageWeb, :router
import MirageWeb.UserAuth
def fetch_settings(conn, _opts) do
settings = Mirage.Settings.list_settings_as_map()
assign(conn, :_s, settings)
pipeline :browser do
plug :accepts, ["html"]
plug :fetch_session
plug :fetch_settings
plug :fetch_live_flash
plug :put_root_layout, {MirageWeb.LayoutView, :root}
plug :protect_from_forgery
plug :put_secure_browser_headers
plug :fetch_current_user
pipeline :api do
plug :accepts, ["json"]
scope "/", MirageWeb do
pipe_through :browser
live "/", PageLive, :index
resources "/notes", NoteController, except: [:show]
resources "/topics", TopicController
resources "/settings", SettingController, only: [:index, :show, :edit, :update]
live "/notes/:id", ShowNoteLive
scope "/user", MirageWeb do
pipe_through [:browser, :require_authenticated_user]
get "/", UserController, :index
# Other scopes may use custom stacks.
# scope "/api", MirageWeb do
# pipe_through :api
# end
# Enables LiveDashboard only for development
# 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).
if Mix.env() in [:dev, :test] do
import Phoenix.LiveDashboard.Router
scope "/" do
pipe_through :browser
live_dashboard "/dashboard",
metrics: MirageWeb.Telemetry,
ecto_repos: [Mirage.Repo]
## Authentication routes
scope "/", MirageWeb do
pipe_through [:browser, :redirect_if_user_is_authenticated]
get "/user/register", UserRegistrationController, :new
post "/user/register", UserRegistrationController, :create
get "/user/log_in", UserSessionController, :new
post "/user/log_in", UserSessionController, :create
get "/user/reset_password", UserResetPasswordController, :new
post "/user/reset_password", UserResetPasswordController, :create
get "/user/reset_password/:token", UserResetPasswordController, :edit
put "/user/reset_password/:token", UserResetPasswordController, :update
scope "/", MirageWeb do
pipe_through [:browser, :require_authenticated_user]
get "/user/settings", UserSettingsController, :edit
put "/user/settings", UserSettingsController, :update
get "/user/settings/confirm_email/:token", UserSettingsController, :confirm_email
scope "/", MirageWeb do
pipe_through [:browser]
delete "/user/log_out", UserSessionController, :delete
get "/user/confirm", UserConfirmationController, :new
post "/user/confirm", UserConfirmationController, :create
get "/user/confirm/:token", UserConfirmationController, :confirm