Feature: Option to disable use signups using env

This commit is contained in:
navaneeth 2021-05-16 22:26:48 +05:30
parent c9ace3d1e7
commit 463f147ccd
2 changed files with 14 additions and 6 deletions

View file

@ -13,3 +13,6 @@ SMTP_USERNAME=
SMTP_PASSWORD=
SMTP_DOMAIN=
SMTP_ADDRESS=
# DISABLE USER SIGNUPS (true or false)
DISABLE_SIGNUPS=

View file

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