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).
|
# Ignore all environment files (except templates).
|
||||||
/.env*
|
/.env*
|
||||||
!/.env*.erb
|
!/.env*.erb
|
||||||
|
!/.env.development
|
||||||
|
!/.env.test
|
||||||
|
|
||||||
# Ignore all logfiles and tempfiles.
|
# Ignore all logfiles and tempfiles.
|
||||||
/log/*
|
/log/*
|
||||||
|
|
1
Gemfile
1
Gemfile
|
@ -24,6 +24,7 @@ gem "active_storage_validations"
|
||||||
|
|
||||||
group :development, :test do
|
group :development, :test do
|
||||||
gem "debug", platforms: %i[ mri windows ]
|
gem "debug", platforms: %i[ mri windows ]
|
||||||
|
gem "dotenv"
|
||||||
end
|
end
|
||||||
|
|
||||||
group :development do
|
group :development do
|
||||||
|
|
|
@ -107,6 +107,7 @@ GEM
|
||||||
debug (1.9.2)
|
debug (1.9.2)
|
||||||
irb (~> 1.10)
|
irb (~> 1.10)
|
||||||
reline (>= 0.3.8)
|
reline (>= 0.3.8)
|
||||||
|
dotenv (3.1.2)
|
||||||
drb (2.2.1)
|
drb (2.2.1)
|
||||||
erubi (1.12.0)
|
erubi (1.12.0)
|
||||||
et-orbi (1.2.11)
|
et-orbi (1.2.11)
|
||||||
|
@ -330,6 +331,7 @@ DEPENDENCIES
|
||||||
bootsnap
|
bootsnap
|
||||||
capybara
|
capybara
|
||||||
debug
|
debug
|
||||||
|
dotenv
|
||||||
image_processing (~> 1.2)
|
image_processing (~> 1.2)
|
||||||
importmap-rails
|
importmap-rails
|
||||||
jbuilder
|
jbuilder
|
||||||
|
|
|
@ -6,10 +6,14 @@ class UsersController < ApplicationController
|
||||||
before_action :ensure_self, only: [ :edit, :update ]
|
before_action :ensure_self, only: [ :edit, :update ]
|
||||||
|
|
||||||
def new
|
def new
|
||||||
|
redirect_to :root and return unless ActiveModel::Type::Boolean.new.cast(ENV.fetch("ENABLE_SIGNUP") { false })
|
||||||
|
|
||||||
@user = User.new
|
@user = User.new
|
||||||
end
|
end
|
||||||
|
|
||||||
def create
|
def create
|
||||||
|
redirect_to :root and return unless ActiveModel::Type::Boolean.new.cast(ENV.fetch("ENABLE_SIGNUP") { false })
|
||||||
|
|
||||||
@user = User.new(new_user_params)
|
@user = User.new(new_user_params)
|
||||||
if @user.save
|
if @user.save
|
||||||
token = @user.generate_token_for(:email_verification)
|
token = @user.generate_token_for(:email_verification)
|
||||||
|
|
|
@ -28,8 +28,10 @@
|
||||||
<% end %>
|
<% end %>
|
||||||
<% else %>
|
<% else %>
|
||||||
<li><%= link_to t("log_in"), login_path %></li>
|
<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>
|
<li><%= link_to t("sign_up"), new_user_path %></li>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
<% end %>
|
||||||
</ul>
|
</ul>
|
||||||
</nav>
|
</nav>
|
||||||
</header>
|
</header>
|
||||||
|
|
|
@ -5,16 +5,18 @@ default: &default
|
||||||
timeout: 5000
|
timeout: 5000
|
||||||
host: <%= ENV.fetch("DB_HOST") { "localhost" } %>
|
host: <%= ENV.fetch("DB_HOST") { "localhost" } %>
|
||||||
username: <%= ENV.fetch("POSTGRES_USER") { "postgres" } %>
|
username: <%= ENV.fetch("POSTGRES_USER") { "postgres" } %>
|
||||||
password: <%= ENV.fetch("POSTGRES_PASSWORD") { "postgres" } %>
|
|
||||||
|
|
||||||
development:
|
development:
|
||||||
<<: *default
|
<<: *default
|
||||||
database: tabletop_companion_development
|
database: tabletop_companion_development
|
||||||
|
password: postgres
|
||||||
|
|
||||||
test:
|
test:
|
||||||
<<: *default
|
<<: *default
|
||||||
database: tabletop_companion_test
|
database: tabletop_companion_test
|
||||||
|
password: postgres
|
||||||
|
|
||||||
production:
|
production:
|
||||||
<<: *default
|
<<: *default
|
||||||
database: tabletop_companion_production
|
database: tabletop_companion_production
|
||||||
|
password: <%= ENV.fetch("POSTGRES_PASSWORD") { "postgres" } %>
|
||||||
|
|
|
@ -43,6 +43,7 @@ env:
|
||||||
clear:
|
clear:
|
||||||
APPLICATION_HOST: ttcompanion.com
|
APPLICATION_HOST: ttcompanion.com
|
||||||
DB_HOST: ttcompanion-postgres
|
DB_HOST: ttcompanion-postgres
|
||||||
|
ENABLE_SIGNUP: false
|
||||||
RAILS_LOG_TO_STDOUT: true
|
RAILS_LOG_TO_STDOUT: true
|
||||||
RAILS_SERVE_STATIC_FILES: true
|
RAILS_SERVE_STATIC_FILES: true
|
||||||
secret:
|
secret:
|
||||||
|
|
|
@ -78,7 +78,7 @@ Rails.application.configure do
|
||||||
config.action_mailer.smtp_settings = {
|
config.action_mailer.smtp_settings = {
|
||||||
address: "smtp.eu.mailgun.org",
|
address: "smtp.eu.mailgun.org",
|
||||||
port: 587,
|
port: 587,
|
||||||
domain: ENV.fetch("APPLICATION_HOST"),
|
domain: "ttcompanion.com",
|
||||||
username: "postmaster@mail.ttcompanion.com",
|
username: "postmaster@mail.ttcompanion.com",
|
||||||
password: Rails.application.credentials.dig(:mailgun, :password),
|
password: Rails.application.credentials.dig(:mailgun, :password),
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue