feat: add toggable registration
Some checks failed
Checks / check (push) Failing after 1m31s
Build and Push Docker Image / Build and Push Image (push) Successful in 1m14s

This commit is contained in:
Vladimir Rubin 2024-11-28 12:31:10 +02:00
parent cb84ba985e
commit cecfb39215
Signed by: vavakado
GPG key ID: CAB744727F36B524
3 changed files with 19 additions and 3 deletions

View file

@ -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") ||

View file

@ -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

View file

@ -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