From e5619547d5544a043dfec173f17020b09f882a98 Mon Sep 17 00:00:00 2001 From: hellekin Date: Thu, 11 Feb 2021 20:40:00 +0100 Subject: [FIX] Availability of agents --- app/controllers/agents_controller.rb | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'app/controllers/agents_controller.rb') diff --git a/app/controllers/agents_controller.rb b/app/controllers/agents_controller.rb index 105e443..fcbaebe 100644 --- a/app/controllers/agents_controller.rb +++ b/app/controllers/agents_controller.rb @@ -3,7 +3,7 @@ # SPDX-License-Identifier: AGPL-3.0-or-later class AgentsController < ApplicationController - before_action :set_agent, only: [:new, :show, :edit, :update, :delete, :destroy] + before_action :set_agent, only: [:new, :show, :edit, :update, :delete, :destroy] # GET /agents def index @@ -26,7 +26,7 @@ class AgentsController < ApplicationController # GET /agents/:id/edit def edit - flash.now[:notice] = 'Please ask a maintainer to edit this resource!' unless current_user_maintainer? + flash.now[:notice] = 'Please ask a maintainer to edit this resource!' unless current_agent == @agent end # PATCH /agents/:id @@ -36,7 +36,7 @@ class AgentsController < ApplicationController # 2. Validate each change # 3. Moderate queue or save - return 403 unless current_user_maintainer? + return 403 unless current_agent == @agent respond_to do |format| if @agent.update(agent_params) @@ -51,7 +51,7 @@ class AgentsController < ApplicationController # GET /agents/:id/delete def delete - flash.now[:notice] = 'Please ask a maintainer to delete your Agent!' unless current_user_maintainer? + flash.now[:notice] = 'Please ask a maintainer to delete your Agent!' unless current_agent == @agent end # DELETE /agents/:id @@ -59,7 +59,7 @@ class AgentsController < ApplicationController return 403 # Yeah, right? # Check list # 1. User belongs to Agent and is :maintainer? - if !(current_user_maintainer? && current_user_leader?) + unless current_agent == @agent msg = 'You must be a maintainer and a leader to delete your Agent!' respond_to do |format| format.html { redirect_to :show, notice: msg } -- cgit v1.2.3