Disable signup in production

This commit is contained in:
Trevor Vallender 2024-06-19 18:22:20 +01:00
parent 0463e47044
commit 19bdbb12b5
11 changed files with 19 additions and 4 deletions

1
.env.development Normal file
View File

@ -0,0 +1 @@
ENABLE_SIGNUP=true

1
.env.test Normal file
View File

@ -0,0 +1 @@
ENABLE_SIGNUP=true

2
.gitignore vendored
View File

@ -10,6 +10,8 @@
# Ignore all environment files (except templates).
/.env*
!/.env*.erb
!/.env.development
!/.env.test
# Ignore all logfiles and tempfiles.
/log/*

View File

@ -24,6 +24,7 @@ gem "active_storage_validations"
group :development, :test do
gem "debug", platforms: %i[ mri windows ]
gem "dotenv"
end
group :development do

View File

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

View File

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

View File

@ -28,7 +28,9 @@
<% end %>
<% else %>
<li><%= link_to t("log_in"), login_path %></li>
<li><%= link_to t("sign_up"), new_user_path %></li>
<% if ActiveModel::Type::Boolean.new.cast(ENV.fetch("ENABLE_SIGNUP") { false } ) %>
<li><%= link_to t("sign_up"), new_user_path %></li>
<% end %>
<% end %>
</ul>
</nav>

View File

@ -5,16 +5,18 @@ default: &default
timeout: 5000
host: <%= ENV.fetch("DB_HOST") { "localhost" } %>
username: <%= ENV.fetch("POSTGRES_USER") { "postgres" } %>
password: <%= ENV.fetch("POSTGRES_PASSWORD") { "postgres" } %>
development:
<<: *default
database: tabletop_companion_development
password: postgres
test:
<<: *default
database: tabletop_companion_test
password: postgres
production:
<<: *default
database: tabletop_companion_production
password: <%= ENV.fetch("POSTGRES_PASSWORD") { "postgres" } %>

View File

@ -43,6 +43,7 @@ env:
clear:
APPLICATION_HOST: ttcompanion.com
DB_HOST: ttcompanion-postgres
ENABLE_SIGNUP: false
RAILS_LOG_TO_STDOUT: true
RAILS_SERVE_STATIC_FILES: true
secret:

View File

@ -78,7 +78,7 @@ Rails.application.configure do
config.action_mailer.smtp_settings = {
address: "smtp.eu.mailgun.org",
port: 587,
domain: ENV.fetch("APPLICATION_HOST"),
domain: "ttcompanion.com",
username: "postmaster@mail.ttcompanion.com",
password: Rails.application.credentials.dig(:mailgun, :password),
}

View File

@ -1,5 +1,4 @@
- set up email in prod
- disallow unverified accounts
- request invite
- don't move down/up top/bottom features
- auto save text fields