feat: add toggable registration
This commit is contained in:
parent
cb84ba985e
commit
cecfb39215
3 changed files with 19 additions and 3 deletions
|
@ -20,6 +20,14 @@ if System.get_env("PHX_SERVER") do
|
||||||
config :exmr, ExmrWeb.Endpoint, server: true
|
config :exmr, ExmrWeb.Endpoint, server: true
|
||||||
end
|
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
|
if config_env() == :prod do
|
||||||
database_url =
|
database_url =
|
||||||
System.get_env("DATABASE_URL") ||
|
System.get_env("DATABASE_URL") ||
|
||||||
|
|
|
@ -8,7 +8,9 @@ services:
|
||||||
environment:
|
environment:
|
||||||
- DATABASE_URL=${DATABASE_URL}
|
- DATABASE_URL=${DATABASE_URL}
|
||||||
- SECRET_KEY_BASE=${SECRET_KEY_BASE}
|
- SECRET_KEY_BASE=${SECRET_KEY_BASE}
|
||||||
depends_on: db
|
- EXMR_ENABLE_REGISTRATION=true
|
||||||
|
depends_on:
|
||||||
|
- db
|
||||||
|
|
||||||
db:
|
db:
|
||||||
image: postgres:16-alpine
|
image: postgres:16-alpine
|
||||||
|
|
|
@ -52,7 +52,10 @@ defmodule ExmrWeb.Router do
|
||||||
|
|
||||||
live_session :redirect_if_user_is_authenticated,
|
live_session :redirect_if_user_is_authenticated,
|
||||||
on_mount: [{ExmrWeb.UserAuth, :redirect_if_user_is_authenticated}] do
|
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/log_in", UserLoginLive, :new
|
||||||
live "/users/reset_password", UserForgotPasswordLive, :new
|
live "/users/reset_password", UserForgotPasswordLive, :new
|
||||||
live "/users/reset_password/:token", UserResetPasswordLive, :edit
|
live "/users/reset_password/:token", UserResetPasswordLive, :edit
|
||||||
|
@ -66,7 +69,10 @@ defmodule ExmrWeb.Router do
|
||||||
|
|
||||||
live_session :require_authenticated_user,
|
live_session :require_authenticated_user,
|
||||||
on_mount: [{ExmrWeb.UserAuth, :ensure_authenticated}] do
|
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", UserSettingsLive, :edit
|
||||||
live "/users/settings/confirm_email/:token", UserSettingsLive, :confirm_email
|
live "/users/settings/confirm_email/:token", UserSettingsLive, :confirm_email
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue