Fix access restriction in valuation budget investments controller
Since we allow many active budgets at the same time, the controller should now check the budget given by params. Before this change the controller was checking the latest published budget, ignoring the request parameter `budget_id`.
This commit is contained in:
@@ -4,9 +4,9 @@ class Valuation::BudgetInvestmentsController < Valuation::BaseController
|
||||
|
||||
feature_flag :budgets
|
||||
|
||||
before_action :load_budget
|
||||
before_action :restrict_access_to_assigned_items, only: [:show, :edit, :valuate]
|
||||
before_action :restrict_access, only: [:edit, :valuate]
|
||||
before_action :load_budget
|
||||
before_action :load_investment, only: [:show, :edit, :valuate]
|
||||
|
||||
has_orders %w[oldest], only: [:show, :edit]
|
||||
@@ -110,7 +110,7 @@ class Valuation::BudgetInvestmentsController < Valuation::BaseController
|
||||
end
|
||||
|
||||
def restrict_access
|
||||
unless current_user.administrator? || current_budget.valuating?
|
||||
unless current_user.administrator? || @budget.valuating?
|
||||
raise CanCan::AccessDenied, I18n.t("valuation.budget_investments.not_in_valuating_phase")
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user