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.
This commit is contained in:
Christopher Harrington 2023-05-06 21:58:01 -05:00
parent 3897eaa15e
commit 641b07167a
1 changed files with 2 additions and 1 deletions

View File

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