From a6921baace3c2f12cbe98e02533ab053b40983ac Mon Sep 17 00:00:00 2001
From: SaptarshiAI <140164380+SaptarshiAI@users.noreply.github.com>
Date: Sun, 31 May 2026 09:17:36 +0530
Subject: [PATCH] Hide bounty actions for unauthorized users
---
lib/algora_web/live/org/bounties_live.ex | 11 ++++++++---
1 file changed, 8 insertions(+), 3 deletions(-)
diff --git a/lib/algora_web/live/org/bounties_live.ex b/lib/algora_web/live/org/bounties_live.ex
index 9dccffbd2..d26f14a90 100644
--- a/lib/algora_web/live/org/bounties_live.ex
+++ b/lib/algora_web/live/org/bounties_live.ex
@@ -220,7 +220,10 @@ defmodule AlgoraWeb.Org.BountiesLive do
<% end %>
-
+
<.button
phx-click="edit-bounty-amount"
phx-value-id={bounty.id}
@@ -415,7 +418,7 @@ defmodule AlgoraWeb.Org.BountiesLive do
def handle_event("delete-bounty", %{"id" => bounty_id}, socket) do
cond do
- socket.assigns.current_user_role in [:admin, :mod] ->
+ can_manage_bounties?(socket.assigns.current_user_role) ->
bounty =
Bounty
|> Repo.get(bounty_id)
@@ -475,7 +478,7 @@ defmodule AlgoraWeb.Org.BountiesLive do
def handle_event("edit-bounty-amount", %{"id" => bounty_id}, socket) do
cond do
- socket.assigns.current_user_role in [:admin, :mod] ->
+ can_manage_bounties?(socket.assigns.current_user_role) ->
[bounty] = Bounties.list_bounties(id: bounty_id)
changeset = edit_amount_changeset(%{amount: bounty.amount})
@@ -706,4 +709,6 @@ defmodule AlgoraWeb.Org.BountiesLive do
assign(socket, :bounty_rows, to_bounty_rows(bounties))
end
+
+ defp can_manage_bounties?(role), do: role in [:admin, :mod]
end
|