From 641b07167a8d4383037f5869868c162e5aba1202 Mon Sep 17 00:00:00 2001 From: Christopher Harrington Date: Sat, 6 May 2023 21:58:01 -0500 Subject: [PATCH] Review fix: Restructure for early return Per IanWhitney's review, the complex logic with the unless clause is pretty clumsy. We can check this condition first and return false immediately, and leave the remaining logic as a simpler statement on its own. --- app/controllers/api/base_controller.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/controllers/api/base_controller.rb b/app/controllers/api/base_controller.rb index 5c19597e7..226b8b76f 100644 --- a/app/controllers/api/base_controller.rb +++ b/app/controllers/api/base_controller.rb @@ -133,7 +133,8 @@ class Api::BaseController < ApplicationController end def disallow_unauthenticated_api_access? - (ENV['DISALLOW_UNAUTHENTICATED_API_ACCESS'] == 'true' || Rails.configuration.x.whitelist_mode) unless current_user + return false if current_user + ENV['DISALLOW_UNAUTHENTICATED_API_ACCESS'] == 'true' || Rails.configuration.x.whitelist_mode end def user_would_block_unauthenticated_api_access?(account)