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:
parent
5e361ba400
commit
2f67c7099d
2 changed files with 21 additions and 13 deletions
|
|
@ -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>
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue