# `MishkaCmsCore.Accounts.UserPermission`
[🔗](https://github.com/mishka-group/mishka_cms_core/blob/v0.0.1/lib/mishka_cms_core/accounts/user_permission.ex#L5)

Manages the many-to-many relationship between users and permissions.

This resource serves as the join table that associates users with their granted
permissions, forming the foundation of the role-based access control system.
Each record represents a single permission assignment to a user, enabling
fine-grained control over what actions users can perform throughout the system.

The resource implements upsert functionality through the assign action, preventing
duplicate permission assignments while allowing efficient bulk permission updates.
The unique constraint on user_id and permission_id pairs ensures that each user
can only have a permission assigned once, maintaining data integrity.

A row is written through `MishkaCmsCore.Accounts.User`'s own actions, which hold a grant to the
granter's ceiling and keep a site's admin off its own permissions, or directly by a master holding
the permission area (`admin:<surface>:permission`). A site's holder of that area reads the grants
of its own site's users only.

# `t`

```elixir
@type t() :: %MishkaCmsCore.Accounts.UserPermission{
  __lateral_join_source__: term(),
  __meta__: term(),
  __metadata__: term(),
  __order__: term(),
  aggregates: term(),
  calculations: term(),
  created_at: term(),
  id: term(),
  permission: term(),
  permission_id: term(),
  user: term(),
  user_id: term()
}
```

# `default_short_name`

# `input`

```elixir
@spec input(values :: map() | Keyword.t()) :: map() | no_return()
```

Validates that the keys in the provided input are valid for at least one action on the resource.

Raises a KeyError error at compile time if not. This exists because generally a struct should only ever
be created by Ash as a result of a successful action. You should not be creating records manually in code,
e.g `%MyResource{value: 1, value: 2}`. Generally that is fine, but often with embedded resources it is nice
to be able to validate the keys that are being provided, e.g

```elixir
Resource
|> Ash.Changeset.for_create(:create, %{embedded: EmbeddedResource.input(foo: 1, bar: 2)})
|> Ash.create()
```

# `input`

```elixir
@spec input(values :: map() | Keyword.t(), action :: atom()) :: map() | no_return()
```

Same as `input/1`, except restricts the keys to values accepted by the action provided.

# `primary_key_matches?`

---

*Consult [api-reference.md](api-reference.md) for complete listing*
