My space on the web https://inhji.de
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.
 
 
 
 
 

106 lines
3.1 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)
end
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
end
pipeline :api do
plug :accepts, ["json"]
end
scope "/", MirageWeb do
pipe_through :browser
live "/", HomeLive, :index
resources "/notes", NoteController, except: [:show]
resources "/topics", TopicController
resources "/settings", SettingController, only: [:index, :show, :edit, :update]
live "/links", LinkLive.Index, :index
live "/links/new", LinkLive.Index, :new
live "/links/:id/edit", LinkLive.Index, :edit
live "/links/:id", LinkLive.Show, :show
live "/links/:id/show/edit", LinkLive.Show, :edit
live "/notes/:id", ShowNoteLive
end
scope "/user", MirageWeb do
pipe_through [:browser, :require_authenticated_user]
get "/", UserController, :index
end
# 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]
end
end
## 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
end
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
end
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
end
end