diff --git a/.rubocop.yml b/.rubocop.yml index 0d6f51b2a6..fb29a1ecae 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -73,7 +73,7 @@ Metrics/ClassLength: # A calculated magnitude based on number of assignments, # branches, and conditions. Metrics/AbcSize: - Max: 90 + Max: 95 Metrics/ParameterLists: CountKeywordArgs: false @@ -82,10 +82,10 @@ RSpec/AnyInstance: Enabled: false Metrics/CyclomaticComplexity: - Max: 20 + Max: 25 Metrics/PerceivedComplexity: - Max: 20 + Max: 25 Rails/Exit: Exclude: diff --git a/app/controllers/api/v1/users_controller.rb b/app/controllers/api/v1/users_controller.rb index 09c860e4ed..15ad2f57c4 100644 --- a/app/controllers/api/v1/users_controller.rb +++ b/app/controllers/api/v1/users_controller.rb @@ -35,7 +35,7 @@ def show render_data data: user, status: :ok end - # rubocop:disable Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity + # rubocop:disable Metrics/AbcSize # POST /api/v1/users.json # Creates and saves a new user record in the database with the provided parameters def create @@ -62,7 +62,7 @@ def create create_user_params[:language] = current_user&.language || I18n.default_locale if create_user_params[:language].blank? # renders an error if the user is signing up with an invalid domain based off site settings - return render_error errors: Rails.configuration.custom_error_msgs[:unauthorized], status: :forbidden unless valid_domain? + return render_error errors: Rails.configuration.custom_error_msgs[:banned_user], status: :forbidden unless valid_domain? user = UserCreator.new(user_params: create_user_params.except(:invite_token), provider: current_provider, role: default_role).call @@ -97,7 +97,7 @@ def create render_error errors: Rails.configuration.custom_error_msgs[:record_invalid], status: :bad_request end end - # rubocop:enable Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity + # rubocop:enable Metrics/AbcSize # PATCH /api/v1/users/:id.json # Updates the values of a user diff --git a/app/controllers/external_controller.rb b/app/controllers/external_controller.rb index 8b512663b1..d552dae03a 100644 --- a/app/controllers/external_controller.rb +++ b/app/controllers/external_controller.rb @@ -48,9 +48,10 @@ def create_user return redirect_to root_path(error: Rails.configuration.custom_error_msgs[:invite_token_invalid]) end - return render_error status: :forbidden unless valid_domain?(user_info[:email]) + # Redirect to root if the user doesn't exist and has an invalid domain + return redirect_to root_path(error: Rails.configuration.custom_error_msgs[:banned_user]) if new_user && !valid_domain?(user_info[:email]) - # Create the user if they dont exist + # Create the user if they don't exist if new_user user = UserCreator.new(user_params: user_info, provider: current_provider, role: default_role).call user.save! diff --git a/app/javascript/components/admin/site_settings/registration/Registration.jsx b/app/javascript/components/admin/site_settings/registration/Registration.jsx index 7d9029666f..764e5b00f5 100644 --- a/app/javascript/components/admin/site_settings/registration/Registration.jsx +++ b/app/javascript/components/admin/site_settings/registration/Registration.jsx @@ -108,6 +108,7 @@ export default function Registration() {