diff --git a/config/runtime.exs b/config/runtime.exs index 096f7cc..b3d5868 100644 --- a/config/runtime.exs +++ b/config/runtime.exs @@ -20,6 +20,14 @@ if System.get_env("PHX_SERVER") do config :exmr, ExmrWeb.Endpoint, server: true end +if System.get_env("EXMR_ENABLE_REGISTRATION") do + enable_registration = System.get_env("EXMR_ENABLE_REGISTRATION") + + config :exmr, registration_enabled: enable_registration +else + config :exmr, registration_enabled: "true" +end + if config_env() == :prod do database_url = System.get_env("DATABASE_URL") || diff --git a/docker-compose.yml b/docker-compose.yml index ffa2555..b2400b3 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -8,7 +8,9 @@ services: environment: - DATABASE_URL=${DATABASE_URL} - SECRET_KEY_BASE=${SECRET_KEY_BASE} - depends_on: db + - EXMR_ENABLE_REGISTRATION=true + depends_on: + - db db: image: postgres:16-alpine diff --git a/lib/exmr_web/router.ex b/lib/exmr_web/router.ex index 4912a08..248fbdc 100644 --- a/lib/exmr_web/router.ex +++ b/lib/exmr_web/router.ex @@ -52,7 +52,10 @@ defmodule ExmrWeb.Router do live_session :redirect_if_user_is_authenticated, on_mount: [{ExmrWeb.UserAuth, :redirect_if_user_is_authenticated}] do - # live "/users/register", UserRegistrationLive, :new + if Application.get_env(:exmr, :registration_enabled) != "false" do + live "/users/register", UserRegistrationLive, :new + end + live "/users/log_in", UserLoginLive, :new live "/users/reset_password", UserForgotPasswordLive, :new live "/users/reset_password/:token", UserResetPasswordLive, :edit @@ -66,7 +69,10 @@ defmodule ExmrWeb.Router do live_session :require_authenticated_user, on_mount: [{ExmrWeb.UserAuth, :ensure_authenticated}] do - live "/users/register", UserRegistrationLive, :new + if Application.get_env(:exmr, :registration_enabled) == "false" do + live "/users/register", UserRegistrationLive, :new + end + live "/users/settings", UserSettingsLive, :edit live "/users/settings/confirm_email/:token", UserSettingsLive, :confirm_email