Merge pull request #464 from okriuchykhin/ok_SCI_935

Add config option to enable/disable users registration [SCI-935]
This commit is contained in:
okriuchykhin 2017-02-01 09:36:36 +01:00 committed by GitHub
commit 067b9452a4
5 changed files with 18 additions and 1 deletions

View file

@ -122,7 +122,13 @@ class Users::RegistrationsController < Devise::RegistrationsController
end
end
def new
render_403 && return unless Rails.configuration.x.enable_user_registration
end
def create
render_403 && return unless Rails.configuration.x.enable_user_registration
build_resource(sign_up_params)
valid_resource = resource.valid?

View file

@ -2,7 +2,7 @@
<%= link_to t("devise.links.login"), new_session_path(resource_name) %><br />
<% end -%>
<%- if devise_mapping.registerable? && controller_name != 'registrations' %>
<%- if devise_mapping.registerable? && Rails.configuration.x.enable_user_registration && controller_name != 'registrations' %>
<%= link_to t("devise.links.signup"), new_registration_path(resource_name) %><br />
<% end -%>

View file

@ -75,4 +75,8 @@ Rails.application.configure do
# Enable email confirmations
config.x.enable_email_confirmations =
ENV['ENABLE_EMAIL_CONFIRMATIONS'] == 'true'
# Enable user registrations
config.x.enable_user_registration =
ENV['ENABLE_USER_REGISTRATION'] == 'false' ? false : true
end

View file

@ -108,4 +108,8 @@ Rails.application.configure do
# Enable email confirmations
config.x.enable_email_confirmations =
ENV['ENABLE_EMAIL_CONFIRMATIONS'] == 'true'
# Enable user registrations
config.x.enable_user_registration =
ENV['ENABLE_USER_REGISTRATION'] == 'false' ? false : true
end

View file

@ -74,4 +74,7 @@ Rails.application.configure do
# Enable email confirmations
config.x.enable_email_confirmations = false
# Enable user registrations
config.x.enable_user_registration = true
end