app controller: replace calls to access_denied with PrivilegeError.

Standardize controllers to raise User::PrivilegeError instead of calling
`access_denied` directly.
This commit is contained in:
evazion
2019-08-24 22:55:36 -05:00
parent fda9843a55
commit d4c43af1dd
5 changed files with 19 additions and 39 deletions

View File

@@ -23,13 +23,10 @@ class BulkUpdateRequestsController < ApplicationController
end
def update
if @bulk_update_request.editable?(CurrentUser.user)
@bulk_update_request.update(bur_params(:update))
flash[:notice] = "Bulk update request updated"
respond_with(@bulk_update_request, :location => bulk_update_requests_path)
else
access_denied()
end
raise User::PrivilegeError unless @bulk_update_request.editable?(CurrentUser.user)
@bulk_update_request.update(bur_params(:update))
respond_with(@bulk_update_request, location: bulk_update_requests_path, notice: "Bulk update request updated")
end
def approve
@@ -38,13 +35,10 @@ class BulkUpdateRequestsController < ApplicationController
end
def destroy
if @bulk_update_request.rejectable?(CurrentUser.user)
@bulk_update_request.reject!(CurrentUser.user)
flash[:notice] = "Bulk update request rejected"
respond_with(@bulk_update_request, :location => bulk_update_requests_path)
else
access_denied()
end
raise User::PrivilegeError unless @bulk_update_request.rejectable?(CurrentUser.user)
@bulk_update_request.reject!(CurrentUser.user)
respond_with(@bulk_update_request, location: bulk_update_requests_path, notice: "Bulk update request rejected")
end
def index