Disable signup in production
This commit is contained in:
parent
0463e47044
commit
19bdbb12b5
|
@ -0,0 +1 @@
|
|||
ENABLE_SIGNUP=true
|
|
@ -10,6 +10,8 @@
|
|||
# Ignore all environment files (except templates).
|
||||
/.env*
|
||||
!/.env*.erb
|
||||
!/.env.development
|
||||
!/.env.test
|
||||
|
||||
# Ignore all logfiles and tempfiles.
|
||||
/log/*
|
||||
|
|
1
Gemfile
1
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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -28,8 +28,10 @@
|
|||
<% end %>
|
||||
<% else %>
|
||||
<li><%= link_to t("log_in"), login_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>
|
||||
</header>
|
||||
|
|
|
@ -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" } %>
|
||||
|
|
|
@ -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:
|
||||
|
|
|
@ -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),
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue