diff --git a/.env.development b/.env.development new file mode 100644 index 0000000..c664f31 --- /dev/null +++ b/.env.development @@ -0,0 +1 @@ +ENABLE_SIGNUP=true diff --git a/.env.test b/.env.test new file mode 100644 index 0000000..c664f31 --- /dev/null +++ b/.env.test @@ -0,0 +1 @@ +ENABLE_SIGNUP=true diff --git a/.gitignore b/.gitignore index 5fb66c9..7a97e31 100644 --- a/.gitignore +++ b/.gitignore @@ -10,6 +10,8 @@ # Ignore all environment files (except templates). /.env* !/.env*.erb +!/.env.development +!/.env.test # Ignore all logfiles and tempfiles. /log/* diff --git a/Gemfile b/Gemfile index 8b3fc29..4134b9a 100644 --- a/Gemfile +++ b/Gemfile @@ -24,6 +24,7 @@ gem "active_storage_validations" group :development, :test do gem "debug", platforms: %i[ mri windows ] + gem "dotenv" end group :development do diff --git a/Gemfile.lock b/Gemfile.lock index 1a3422c..8050c1c 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -107,6 +107,7 @@ GEM debug (1.9.2) irb (~> 1.10) reline (>= 0.3.8) + dotenv (3.1.2) drb (2.2.1) erubi (1.12.0) et-orbi (1.2.11) @@ -330,6 +331,7 @@ DEPENDENCIES bootsnap capybara debug + dotenv image_processing (~> 1.2) importmap-rails jbuilder diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 1bc8967..c0a9815 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -6,10 +6,14 @@ class UsersController < ApplicationController before_action :ensure_self, only: [ :edit, :update ] def new + redirect_to :root and return unless ActiveModel::Type::Boolean.new.cast(ENV.fetch("ENABLE_SIGNUP") { false }) + @user = User.new end def create + redirect_to :root and return unless ActiveModel::Type::Boolean.new.cast(ENV.fetch("ENABLE_SIGNUP") { false }) + @user = User.new(new_user_params) if @user.save token = @user.generate_token_for(:email_verification) diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb index d844ccd..f8210bf 100644 --- a/app/views/layouts/application.html.erb +++ b/app/views/layouts/application.html.erb @@ -28,7 +28,9 @@ <% end %> <% else %>