Apply UI authorization to User LiveViews (Index and Show)

Gate New User button, Edit and Delete links with can?/3.
Edit button on User Show visible only when user can update the user.
This commit is contained in:
Moritz 2026-02-03 16:35:32 +01:00
parent 5e361ba400
commit 2f67c7099d
Signed by: moritz
GPG key ID: 1020A035E5DD0824
2 changed files with 21 additions and 13 deletions

View file

@ -41,9 +41,11 @@ defmodule MvWeb.UserLive.Show do
<.icon name="hero-arrow-left" />
<span class="sr-only">{gettext("Back to users list")}</span>
</.button>
<.button variant="primary" navigate={~p"/users/#{@user}/edit?return_to=show"}>
<.icon name="hero-pencil-square" /> {gettext("Edit User")}
</.button>
<%= if can?(@current_user, :update, @user) do %>
<.button variant="primary" navigate={~p"/users/#{@user}/edit?return_to=show"}>
<.icon name="hero-pencil-square" /> {gettext("Edit User")}
</.button>
<% end %>
</:actions>
</.header>