Branch
Hash :
e363af80
Author :
Thomas de Grivel
Date :
2022-06-10T10:22:11
wip
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136
defmodule KmxcrmWeb.Router do
use KmxcrmWeb, :router
import KmxcrmWeb.UserAuth
pipeline :admin do
plug Kmxcrm.Plug.EnsureAdmin
plug :put_root_layout, {KmxcrmWeb.LayoutView, "admin.html"}
end
pipeline :api do
plug :accepts, ["json"]
end
pipeline :browser do
plug :accepts, ["html"]
plug :fetch_session
plug :fetch_live_flash
plug :put_root_layout, {KmxcrmWeb.LayoutView, :root}
plug :protect_from_forgery
plug :put_secure_browser_headers
plug :fetch_current_user
end
pipeline :organisation do
plug KmxcrmWeb.Plug.Organisation
end
pipeline :recaptcha do
plug PlugRecaptcha2, recaptcha_secret: Application.get_env(:kmxcrm, :recaptcha_secret)
end
scope "/", KmxcrmWeb do
pipe_through :browser
get "/", PageController, :index
get "/_new_admin", PageController, :new_admin
post "/_new_admin", PageController, :new_admin_post
get "/_confirm", UserConfirmationController, :new
post "/_confirm", UserConfirmationController, :create
get "/_confirm/:token", UserConfirmationController, :edit
post "/_confirm/:token", UserConfirmationController, :update
get "/_avatar/:login/:size/avatar.png", UserController, :avatar
delete "/_log_out", UserSessionController, :delete
end
# Enables the Swoosh mailbox preview in development.
#
# Note that preview only shows emails that were sent by the same
# node running the Phoenix server.
if Mix.env() == :dev do
scope "/dev" do
pipe_through :browser
forward "/mailbox", Plug.Swoosh.MailboxPreview
end
end
## Authentication routes
scope "/", KmxcrmWeb do
pipe_through [:browser, :redirect_if_user_is_authenticated]
get "/_log_in", UserSessionController, :new
get "/_register", UserRegistrationController, :new
get "/_reset_password", UserResetPasswordController, :new
get "/_reset_password/:token", UserResetPasswordController, :edit
put "/_reset_password/:token", UserResetPasswordController, :update
pipe_through :recaptcha
post "/_log_in", UserSessionController, :create
post "/_register", UserRegistrationController, :create
post "/_reset_password", UserResetPasswordController, :create
end
scope "/", KmxcrmWeb do
pipe_through [:browser, :require_authenticated_user]
get "/_settings", UserSettingsController, :edit
put "/_settings", UserSettingsController, :update
get "/_settings/confirm_email/:token", UserSettingsController, :confirm_email
scope "/_u" do
get "/:login", UserController, :show
delete "/:login", UserController, :delete
get "/:login/_edit", UserController, :edit
put "/:login", UserController, :update
get "/:login/totp", UserController, :totp
put "/:login/totp", UserController, :totp_update
delete "/:login/totp", UserController, :totp_delete
end
scope "/_new" do
get "/organisation", OrganisationController, :new
post "/organisation", OrganisationController, :create
end
scope "/_admin", Admin, as: "admin" do
pipe_through :admin
get "/", DashboardController, :index
resources "/organisations", OrganisationController do
get "/add_user/", OrganisationController, :add_user, as: :""
post "/add_user", OrganisationController, :add_user_post, as: :""
get "/remove_user", OrganisationController, :remove_user, as: :""
post "/remove_user", OrganisationController, :remove_user_post, as: :""
end
resources "/users", UserController do
get "/password/edit", UserController, :edit_password, as: :""
put "/password", UserController, :update_password, as: :""
end
import Phoenix.LiveDashboard.Router
live_dashboard "/dashboard", metrics: KmxcrmWeb.Telemetry
end
scope "/:organisation_slug" do
pipe_through :organisation
get "/", OrganisationController, :show
get "/_edit", OrganisationController, :edit
put "/", OrganisationController, :update
get "/contact/new", ContactController, :new
post "/contact", ContactController, :create
get "/contact/:contact_id", ContactController, :show
get "/contact/:contact_id/edit", ContactController, :edit
put "/contact/:contact_id", ContactController, :update
delete "/contact/:contact_id", ContactController, :delete
get "/item/new", ItemController, :new
post "/item", ItemController, :create
get "/item/:item_id", ItemController, :show
end
end
end