PtahUi.Components.EnsurePermissions (PtahUI v0.1.0)

Copy Markdown View Source

Conditionally renders content based on a user's permission map.

Expects user.staff.role.permissions to be a map of %{scope => [action]}.

Example

<.ensure_permissions user={@current_user} permissions=%{users: ["read"]}>
  <.button>Ver utilizadores</.button>
</.ensure_permissions>

Summary

Functions

Returns true when the user has all required permissions.

Functions

ensure_permissions(assigns)

Attributes

  • user (:map) (required)
  • permissions (:map) (required) - Map of %{scope_atom => [action_string]} required to render the slot.

Slots

  • inner_block (required)

has_permissions?(user, required)

Returns true when the user has all required permissions.