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:
parent
b08c1a2285
commit
e6b26c7ed4
2 changed files with 2 additions and 3 deletions
|
|
@ -4,7 +4,7 @@ module Api
|
|||
respond_to :json
|
||||
|
||||
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 :authorize_user_organization
|
||||
|
|
@ -49,7 +49,7 @@ module Api
|
|||
return unless 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
|
||||
|
||||
def load_owner
|
||||
|
|
|
|||
|
|
@ -1 +0,0 @@
|
|||
class UnauthorizedError < StandardError; end
|
||||
Loading…
Add table
Reference in a new issue