aboutsummaryrefslogtreecommitdiff
path: root/app/controllers/agents_controller.rb
diff options
context:
space:
mode:
Diffstat (limited to 'app/controllers/agents_controller.rb')
-rw-r--r--app/controllers/agents_controller.rb10
1 files changed, 5 insertions, 5 deletions
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 }