diff --git a/.env.example b/.env.example index a6c4ee466f..4a01bf885a 100644 --- a/.env.example +++ b/.env.example @@ -13,3 +13,6 @@ SMTP_USERNAME= SMTP_PASSWORD= SMTP_DOMAIN= SMTP_ADDRESS= + +# DISABLE USER SIGNUPS (true or false) +DISABLE_SIGNUPS= diff --git a/app/controllers/authentication_controller.rb b/app/controllers/authentication_controller.rb index 3849fda0d2..0f584b8a69 100644 --- a/app/controllers/authentication_controller.rb +++ b/app/controllers/authentication_controller.rb @@ -14,13 +14,18 @@ class AuthenticationController < ApplicationController end def signup - email = params[:email] - password = SecureRandom.uuid - org = Organization.create(name: 'new org') - user = User.create(email: email, password: password, organization: org) + # Check if the installation allows user signups + if(ENV['DISABLE_SIGNUPS'] === "true") + render json: {}, status: 500 + else + email = params[:email] + password = SecureRandom.uuid + org = Organization.create(name: 'new org') + user = User.create(email: email, password: password, organization: org) - org_user = OrganizationUser.create(user: user, organization: org, role: 'admin') + org_user = OrganizationUser.create(user: user, organization: org, role: 'admin') - UserMailer.with(user: user, sender: @current_user).new_signup_email.deliver if org_user.save + UserMailer.with(user: user, sender: @current_user).new_signup_email.deliver if org_user.save + end end end