diff --git a/.env_sample b/.env_sample index cf3c5b010..6bcadb369 100644 --- a/.env_sample +++ b/.env_sample @@ -1,7 +1,9 @@ -# App domain + Protocol setting for development +# App core values export APP_DOMAIN="localhost:3000" export APP_PROTOCOL="http://" export APP_NAME="forem_local" +export FOREM_OWNER_SECRET="secret" + # Openresty domain + Protocol setting for development export OPENRESTY_DOMAIN="" diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 7ea6b0665..586f5fc2f 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -17,7 +17,14 @@ class ApplicationController < ActionController::Base error_too_many_requests(exc) end - PUBLIC_CONTROLLERS = %w[shell async_info ga_events service_worker omniauth_callbacks registrations].freeze + PUBLIC_CONTROLLERS = %w[shell + async_info + ga_events + service_worker + omniauth_callbacks + registrations + confirmations + passwords].freeze private_constant :PUBLIC_CONTROLLERS def verify_private_forem diff --git a/app/controllers/registrations_controller.rb b/app/controllers/registrations_controller.rb index 92c55fcff..b9bfa22f9 100644 --- a/app/controllers/registrations_controller.rb +++ b/app/controllers/registrations_controller.rb @@ -13,6 +13,8 @@ class RegistrationsController < Devise::RegistrationsController def create not_authorized unless SiteConfig.allow_email_password_registration || SiteConfig.waiting_on_first_user + not_authorized if SiteConfig.waiting_on_first_user && ENV["FOREM_OWNER_SECRET"].present? && + ENV["FOREM_OWNER_SECRET"] != params[:user][:forem_owner_secret] build_resource(sign_up_params) resource.saw_onboarding = false diff --git a/app/views/shared/authentication/_email_registration_form.html.erb b/app/views/shared/authentication/_email_registration_form.html.erb index 75fce7338..740915de8 100644 --- a/app/views/shared/authentication/_email_registration_form.html.erb +++ b/app/views/shared/authentication/_email_registration_form.html.erb @@ -48,6 +48,12 @@ <%= f.password_field :password_confirmation, autocomplete: "current-password", class: "crayons-textfield", required: true %> + <% if ENV["FOREM_OWNER_SECRET"].present? && SiteConfig.waiting_on_first_user %> +