Favoring re-use of authorization error (#16992)

We only have one reference to the UnauthorizedError, which is shadows
the ApplicationPolicy::NotAuthorizedError.  This commit removes the
exception.

Related to forem/forem#16985 but only barely
This commit is contained in:
Jeremy Friesen 2022-03-24 08:16:28 -04:00 committed by GitHub
parent b08c1a2285
commit e6b26c7ed4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 2 additions and 3 deletions

View file

@ -4,7 +4,7 @@ module Api
respond_to :json respond_to :json
rescue_from ArgumentError, with: :error_unprocessable_entity rescue_from ArgumentError, with: :error_unprocessable_entity
rescue_from UnauthorizedError, with: :error_unauthorized rescue_from ApplicationPolicy::NotAuthorizedError, with: :error_unauthorized
before_action :authenticate_with_api_key_or_current_user! before_action :authenticate_with_api_key_or_current_user!
before_action :authorize_user_organization before_action :authorize_user_organization
@ -49,7 +49,7 @@ module Api
return unless analytics_params[:organization_id] return unless analytics_params[:organization_id]
@org = Organization.find_by(id: analytics_params[:organization_id]) @org = Organization.find_by(id: analytics_params[:organization_id])
raise UnauthorizedError unless @org && @user.org_member?(@org) raise ApplicationPolicy::NotAuthorizedError unless @org && @user.org_member?(@org)
end end
def load_owner def load_owner

View file

@ -1 +0,0 @@
class UnauthorizedError < StandardError; end